--- /dev/null
+Kangho Hur <kanho.hur at samsung dot com>
+Seungkeun Lee <sngn.lee at samsung dot com>
--- /dev/null
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-media-radio")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog mm-radio capi-base-common")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/media
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/media)
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+#ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/media
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_RADIO_H__
+#define __TIZEN_MEDIA_RADIO_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RADIO_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x70
+
+/**
+ * @file radio.h
+ * @brief This file contains the radio API.
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_RADIO_MODULE
+ * @{
+ */
+
+/**
+ * @brief Radio handle type.
+ */
+typedef struct radio_s *radio_h;
+
+/**
+ * @brief Enumerations of radio state
+ */
+typedef enum
+{
+ RADIO_STATE_READY, /**< Ready to play or scan */
+ RADIO_STATE_PLAYING, /**< Playing audio from the tuner */
+ RADIO_STATE_SCANNING, /**< Scanning Searching for the next station signal starts from a given starting frequency */
+} radio_state_e;
+
+/**
+ * @brief Error codes for radio
+ */
+typedef enum
+{
+ RADIO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ RADIO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ RADIO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ RADIO_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ RADIO_ERROR_INVALID_STATE = RADIO_ERROR_CLASS | 0x01 , /**< Invalid state */
+ RADIO_ERROR_SOUND_POLICY = RADIO_ERROR_CLASS | 0x02 , /**< Sound policy error */
+} radio_error_e;
+
+/**
+ * @brief Enumerations of radio interrupted type
+ */
+typedef enum
+{
+ RADIO_INTERRUPTED_BY_MEDIA = 0, /**< Interrupted by non-resumable media application*/
+ RADIO_INTERRUPTED_BY_CALL_START, /**< Interrupted by call starting*/
+ RADIO_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/
+ RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/
+ RADIO_INTERRUPTED_BY_ALARM_START, /**< Interrupted by alarm starting*/
+ RADIO_INTERRUPTED_BY_ALARM_END, /**< Interrupted by alarm ending*/
+ RADIO_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by emergency*/
+ RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by resumable media application*/
+} radio_interrupted_code_e;
+
+/**
+ * @brief Called when the scan information is updated.
+ * @param[in] frequency The tuned radio frequency [87500 ~ 108000] (kHz)
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre It will be invoked by radio_scan_start()
+ * @see radio_scan_start()
+ */
+typedef void (*radio_scan_updated_cb)(int frequency, void *user_data);
+
+/**
+ * @brief Called when the radio scan is stopped.
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre It will be invoked when scan is stopped by radio_scan_stop()
+ * @see radio_scan_stop()
+ */
+typedef void (*radio_scan_stopped_cb)(void *user_data);
+
+/**
+ * @brief Called when the radio scan is completed.
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre It will be invoked when scan is completed if you register this callback using radio_set_scan_completed_cb()
+ * @see radio_scan_start()
+ * @see radio_set_scan_completed_cb()
+ * @see radio_unset_scan_completed_cb()
+ */
+typedef void (*radio_scan_completed_cb)(void *user_data);
+
+/**
+ * @brief Called when the radio seek is completed.
+ * @param[in] frequency The current frequency [87500 ~ 108000] (kHz)
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre It will be invoked when radio seek completed if you register this callback using radio_seek_up() or radio_seek_down()
+ * @see radio_seek_up()
+ * @see radio_seek_down()
+ */
+typedef void (*radio_seek_completed_cb)(int frequency, void *user_data);
+
+/**
+ * @brief Called when the radio is interrupted.
+ * @param[in] error_code The interrupted error code
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see radio_set_interrupted_cb()
+ * @see radio_unset_interrupted_cb()
+ */
+typedef void (*radio_interrupted_cb)(radio_interrupted_code_e code, void *user_data);
+
+/**
+ * @brief Creates a radio handle.
+ * @remarks @a radio must be released radio_destroy() by you.
+ * @param[out] radio A new handle to radio
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_destroy()
+ */
+int radio_create(radio_h *radio);
+
+/**
+ * @brief Destroys the radio handle and releases all its resources.
+ *
+ * @remarks To completely shutdown radio operation, call this function with a valid radio handle.
+ *
+ * @param[in] radio The handle to radio to be destroyed
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_create()
+ */
+int radio_destroy(radio_h radio);
+
+/**
+ * @brief Gets the radio's current state.
+ * @param[in] radio The handle to radio
+ * @param[out] state The current state of the radio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int radio_get_state(radio_h radio, radio_state_e *state);
+
+/**
+ * @brief Starts playing radio.
+ *
+ * @param[in] radio The handle to radio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @retval #RADIO_ERROR_SOUND_POLICY Sound policy error
+ * @pre The radio state must be #RADIO_STATE_READY by radio_create().
+ * @post The radio state will be #RADIO_STATE_PLAYING.
+ * @see radio_stop()
+ */
+int radio_start(radio_h radio);
+
+/**
+ * @brief Stops playing radio.
+ * @param[in] radio The handle to radio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid state
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @pre The radio state must be either #RADIO_STATE_PLAYING by radio_start().
+ * @post The radio state will be #RADIO_STATE_READY.
+ * @see radio_start()
+ * @see radio_scan_start()
+ */
+int radio_stop(radio_h radio);
+
+/**
+ * @brief Seeks up the effective frequency of radio, asynchronously.
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @pre The radio state must be #RADIO_STATE_PLAYING by radio_start().
+ * @post It invokes radio_seek_completed_cb() when seek completes.
+ * @see radio_seek_down()
+ */
+int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_data );
+
+/**
+ * @brief Seeks down the effective frequency of radio, asynchronously.
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @pre The radio state must be #RADIO_STATE_PLAYING by radio_start().
+ * @post It invokes radio_seek_completed_cb() when seek completes.
+ * @see radio_seek_up()
+ */
+int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_data );
+
+/**
+ * @brief Sets the radio frequency.
+ * @param[in] radio The handle to radio
+ * @param[in] percent The frequency to set [87500 ~ 108000] (kHz)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_get_frequency()
+ */
+int radio_set_frequency(radio_h radio, int frequency);
+
+/**
+ * @brief Gets the current frequency of radio.
+ * @param[in] radio The handle to radio
+ * @param[out] frequency The current frequency [87500 ~ 108000] (kHz)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_set_frequency()
+ */
+int radio_get_frequency(radio_h radio, int *frequency);
+
+/**
+ * @brief Gets the current signal strength of radio.
+ * @param[in] radio The handle to radio
+ * @param[out] strength The current signal strength [0 ~ 65535] (dbuV)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+int radio_get_signal_strength(radio_h radio, int *strength);
+
+/**
+ * @brief Starts scanning radio signals, asynchronously
+ *
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @pre The radio state must be #RADIO_STATE_READY by either radio_create() or radio_stop().
+ * @post The radio state will be #RADIO_STATE_SCANNING during searching. After scan is completed, radio state will be #RADIO_STATE_READY.
+ * @post It invokes radio_scan_updated_cb() when the scan information updates.
+ * @post It invokes radio_scan_completed_cb() when scan completes, if you set a callback with radio_set_scan_completed_cb().
+ * @see radio_scan_stop()
+ * @see radio_set_scan_completed_cb()
+ * @see radio_scan_completed_cb()
+ */
+int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data);
+
+/**
+ * @brief Stops scanning radio signals, asynchronously.
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid state
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_INVALID_STATE Invalid radio state
+ * @pre The radio state must be #RADIO_STATE_SCANNING by radio_scan_start().
+ * @post It invokes radio_scan_stopped_cb() when the scan stops.
+ * @post The radio state will be #RADIO_STATE_READY.
+ * @see radio_scan_start()
+ */
+int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data);
+
+/**
+ * @brief Sets the radio's mute status.
+ * @details If the mute status is @c true, no sounds will be played. If @c false, sounds will be played. Until this function is called, by default the radio is not muted.
+ * @param[in] radio The handle to radio
+ * @param[in] muted New mute status: (@c true = mute, @c false = not muted)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_is_muted()
+ */
+int radio_set_mute(radio_h radio, bool muted);
+
+/**
+ * @brief Gets the radio's mute status.
+ * @details If the mute status is @c true, no sounds are played. If @c false, sounds are played.
+ * @param[in] radio The handle to radio
+ * @param[out] muted The current mute status: (@c true = mute, @c false = not muted)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_set_mute()
+ */
+int radio_is_muted(radio_h radio, bool *muted);
+
+/**
+ * @brief Registers a callback function to be invoked when the scan finishes.
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @post radio_scan_completed_cb() will be invoked
+ * @see radio_unset_scan_completed_cb()
+ * @see radio_scan_completed_cb()
+ */
+int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @param[in] radio The handle to radio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_set_scan_completed_cb()
+ */
+int radio_unset_scan_completed_cb(radio_h radio);
+
+/**
+ * @brief Registers a callback function to be invoked when the radio is interrupted.
+ * @param[in] radio The handle to radio
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @post radio_interrupted_cb() will be invoked
+ * @see radio_unset_interrupted_cb()
+ * @see #radio_interrupted_code_e
+ * @see radio_interrupted_cb()
+ */
+int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @param[in] radio The handle to radio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_set_interrupted_cb()
+ */
+int radio_unset_interrupted_cb(radio_h radio);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_RADIO_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_RADIO_PRIVATE_H__
+#define __TIZEN_MEDIA_RADIO_PRIVATE_H__
+#include <radio.h>
+#include <mm_radio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ _RADIO_EVENT_TYPE_SCAN_INFO,
+ _RADIO_EVENT_TYPE_SCAN_STOP,
+ _RADIO_EVENT_TYPE_SCAN_FINISH,
+ _RADIO_EVENT_TYPE_SEEK_FINISH,
+ _RADIO_EVENT_TYPE_INTERRUPT,
+ _RADIO_EVENT_TYPE_NUM
+}_radio_event_e;
+
+typedef struct _radio_s{
+ MMHandleType mm_handle;
+ const void* user_cb[_RADIO_EVENT_TYPE_NUM];
+ void* user_data[_RADIO_EVENT_TYPE_NUM];
+ radio_state_e state;
+ bool mute;
+} radio_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_MEDIA_RADIO_PRIVATE_H__
--- /dev/null
+#sbs-git:slp/api/radio capi-media-radio 0.1.0 59dddd8ea3de373c44c66ce2a298ca81240305a8
+Name: capi-media-radio
+Summary: A Radio library in Tizen Native API
+Version: 0.1.0
+Release: 10
+Group: TO_BE_FILLED
+License: TO_BE_FILLED
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(mm-radio)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: cmake
+BuildRequires: gettext-devel
+
+%description
+A Radio library in Tizen Native API
+
+
+%package devel
+Summary: A Radio library in Tizen Native API (Developement)
+Group: TO_BE_FILLED
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+A Radio library in Tizen Native API (Developement)
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post
+
+%postun
+
+
+%files
+%manifest capi-media-radio.manifest
+%defattr(-,root,root,-)
+/usr/lib/libcapi-media-radio.so.*
+
+%files devel
+%defattr(-,root,root,-)
+/usr/include/media/radio.h
+/usr/lib/pkgconfig/capi-media-radio.pc
+/usr/lib/libcapi-media-radio.so
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mm_types.h>
+#include <radio_private.h>
+#include <dlog.h>
+#include <glib.h>
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_RADIO"
+
+/*
+* Internal Macros
+*/
+#define RADIO_CHECK_CONDITION(condition,error,msg) \
+ if(condition) {} else \
+ { LOGE("[%s] %s(0x%08x)",(char*)__FUNCTION__, msg,error); return error;}; \
+
+#define RADIO_INSTANCE_CHECK(radio) \
+ RADIO_CHECK_CONDITION(radio != NULL, RADIO_ERROR_INVALID_PARAMETER,"RADIO_ERROR_INVALID_PARAMETER")
+
+#define RADIO_STATE_CHECK(radio,expected_state) \
+ RADIO_CHECK_CONDITION(radio->state == expected_state,RADIO_ERROR_INVALID_STATE,"RADIO_ERROR_INVALID_STATE")
+
+#define RADIO_NULL_ARG_CHECK(arg) \
+ RADIO_CHECK_CONDITION(arg != NULL,RADIO_ERROR_INVALID_PARAMETER,"RADIO_ERROR_INVALID_PARAMETER")
+
+/*
+* Internal Implementation
+*/
+static int __convert_error_code(int code, char *func_name)
+{
+ int ret = RADIO_ERROR_NONE;
+ char* msg="RADIO_ERROR_NONE";
+ switch(code)
+ {
+ case MM_ERROR_NONE:
+ ret = RADIO_ERROR_NONE;
+ msg = "RADIO_ERROR_NONE";
+ break;
+
+ case MM_ERROR_RADIO_NO_FREE_SPACE:
+ ret = RADIO_ERROR_OUT_OF_MEMORY;
+ msg = "RADIO_ERROR_OUT_OF_MEMORY";
+ break;
+ case MM_ERROR_RADIO_NOT_INITIALIZED:
+ case MM_ERROR_RADIO_NO_OP:
+ ret = RADIO_ERROR_INVALID_STATE;
+ msg = "RADIO_ERROR_INVALID_STATE";
+ break;
+ case MM_ERROR_COMMON_INVALID_ARGUMENT:
+ ret = RADIO_ERROR_INVALID_PARAMETER;
+ msg = "RADIO_ERROR_INVALID_PARAMETER";
+ break;
+ case MM_ERROR_POLICY_BLOCKED:
+ case MM_ERROR_POLICY_INTERRUPTED:
+ case MM_ERROR_POLICY_INTERNAL:
+ case MM_ERROR_POLICY_DUPLICATED:
+ ret = RADIO_ERROR_SOUND_POLICY;
+ msg = "RADIO_ERROR_SOUND_POLICY";
+ break;
+ case MM_ERROR_RADIO_INTERNAL:
+ case MM_ERROR_RADIO_RESPONSE_TIMEOUT:
+ case MM_ERROR_RADIO_DEVICE_NOT_OPENED:
+ case MM_ERROR_RADIO_DEVICE_NOT_FOUND:
+ default :
+ ret= RADIO_ERROR_INVALID_OPERATION;
+ msg = "RADIO_ERROR_INVALID_OPERATION";
+ }
+ LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code);
+ return ret;
+}
+
+static radio_state_e __convert_radio_state(MMRadioStateType state)
+{
+ int converted_state = RADIO_STATE_READY;
+ switch(state)
+ {
+
+ case MM_RADIO_STATE_PLAYING:
+ converted_state = RADIO_STATE_PLAYING;
+ break;
+ case MM_RADIO_STATE_SCANNING:
+ converted_state = RADIO_STATE_SCANNING;
+ break;
+ case MM_RADIO_STATE_NULL:
+ case MM_RADIO_STATE_READY:
+ default:
+ converted_state = RADIO_STATE_READY;
+ break;
+ }
+ return converted_state;
+}
+
+static int __set_callback(_radio_event_e type, radio_h radio, void* callback, void *user_data)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ RADIO_NULL_ARG_CHECK(callback);
+ radio_s * handle = (radio_s *) radio;
+ handle->user_cb[type] = callback;
+ handle->user_data[type] = user_data;
+ LOGI("[%s] Event type : %d ",__FUNCTION__, type);
+ return RADIO_ERROR_NONE;
+}
+
+static int __unset_callback(_radio_event_e type, radio_h radio)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ handle->user_cb[type] = NULL;
+ handle->user_data[type] = NULL;
+ LOGI("[%s] Event type : %d ",__FUNCTION__, type);
+ return RADIO_ERROR_NONE;
+}
+
+static int __msg_callback(int message, void *param, void *user_data)
+{
+ radio_s * handle = (radio_s*)user_data;
+ MMMessageParamType *msg = (MMMessageParamType*)param;
+ LOGI("[%s] Got message type : 0x%x" ,__FUNCTION__, message);
+ switch(message)
+ {
+ case MM_MESSAGE_RADIO_SCAN_INFO:
+ if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO] )
+ {
+ ((radio_scan_updated_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])(msg->radio_scan.frequency,handle->user_data[_RADIO_EVENT_TYPE_SCAN_INFO]);
+ }
+ break;
+ case MM_MESSAGE_RADIO_SCAN_STOP:
+ if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP] )
+ {
+ ((radio_scan_stopped_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_STOP]);
+ }
+ break;
+ case MM_MESSAGE_RADIO_SCAN_FINISH:
+ if( handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH] )
+ {
+ ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]);
+ }
+ break;
+ case MM_MESSAGE_RADIO_SEEK_FINISH:
+ if( handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH] )
+ {
+ ((radio_seek_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SEEK_FINISH]);
+ }
+ break;
+ case MM_MESSAGE_STATE_INTERRUPTED:
+ if( handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT] )
+ {
+ ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(msg->code,handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
+ }
+ break;
+ case MM_MESSAGE_ERROR:
+ __convert_error_code(msg->code,(char*)__FUNCTION__);
+ break;
+ case MM_MESSAGE_RADIO_SCAN_START:
+ LOGI("[%s] Scan Started");
+ break;
+ case MM_MESSAGE_STATE_CHANGED:
+ handle->state = __convert_radio_state(msg->state.current);
+ LOGI("[%s] State Changed --- from : %d , to : %d" ,__FUNCTION__, __convert_radio_state(msg->state.previous), handle->state);
+ break;
+ case MM_MESSAGE_RADIO_SEEK_START:
+ LOGI("[%s] Seek Started", __FUNCTION__);
+ break;
+ default:
+ break;
+ }
+ return 1;
+}
+
+
+/*
+* Public Implementation
+*/
+int radio_create(radio_h *radio)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle;
+ handle = (radio_s*)malloc( sizeof(radio_s));
+ if (handle != NULL)
+ memset(handle, 0 , sizeof(radio_s));
+ else
+ {
+ LOGE("[%s] RADIO_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,RADIO_ERROR_OUT_OF_MEMORY);
+ return RADIO_ERROR_OUT_OF_MEMORY;
+ }
+ int ret = mm_radio_create(&handle->mm_handle);
+ if( ret != MM_ERROR_NONE)
+ {
+ LOGE("[%s] RADIO_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,RADIO_ERROR_INVALID_OPERATION);
+ free(handle);
+ handle=NULL;
+ return RADIO_ERROR_INVALID_OPERATION;
+ }
+ else
+ {
+ *radio = (radio_h)handle;
+
+ ret = mm_radio_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret);
+ }
+ ret = mm_radio_realize(handle->mm_handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ handle->state = RADIO_STATE_READY;
+ handle->mute = FALSE;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_destroy(radio_h radio)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+
+ int ret;
+ ret = mm_radio_unrealize(handle->mm_handle);
+ if ( ret!= MM_ERROR_NONE)
+ {
+ LOGW("[%s] Failed to unrealize (0x%x)" ,__FUNCTION__, ret);
+ }
+
+ ret = mm_radio_destroy(handle->mm_handle);
+ if (ret!= MM_ERROR_NONE)
+ {
+ LOGE("[%s] RADIO_ERROR_INVALID_OPERATION (0x%08x)" ,__FUNCTION__,RADIO_ERROR_INVALID_OPERATION);
+ return RADIO_ERROR_INVALID_OPERATION;
+ }
+ else
+ {
+ free(handle);
+ handle= NULL;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_get_state(radio_h radio, radio_state_e *state)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ RADIO_NULL_ARG_CHECK(state);
+ radio_s * handle = (radio_s *) radio;
+ MMRadioStateType currentStat = MM_RADIO_STATE_NULL;
+ int ret = mm_radio_get_state(handle->mm_handle, ¤tStat);
+ if(ret != MM_ERROR_NONE)
+ {
+ *state = handle->state;
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->state = __convert_radio_state(currentStat);
+ *state = handle->state;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_start(radio_h radio)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_READY);
+
+ int ret = mm_radio_start(handle->mm_handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->state = RADIO_STATE_PLAYING;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_stop(radio_h radio)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+
+ int ret = mm_radio_stop(handle->mm_handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->state = RADIO_STATE_READY;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_seek_up(radio_h radio,radio_seek_completed_cb callback, void *user_data )
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+
+ if(callback!=NULL)
+ {
+ __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio,callback,user_data);
+ }
+ else
+ {
+ __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio);
+ }
+
+ int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_UP);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_seek_down(radio_h radio,radio_seek_completed_cb callback, void *user_data )
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING);
+
+ if(callback!=NULL)
+ {
+ __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio,callback,user_data);
+ }
+ else
+ {
+ __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio);
+ }
+
+ int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_DOWN);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_set_frequency(radio_h radio, int frequency)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ if(frequency < 87500 || frequency > 108000)
+ {
+ LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)" ,__FUNCTION__,RADIO_ERROR_INVALID_PARAMETER);
+ return RADIO_ERROR_INVALID_PARAMETER;
+ }
+ int freq= frequency;
+ radio_s * handle = (radio_s *) radio;
+ int ret = mm_radio_set_frequency(handle->mm_handle, freq);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_get_frequency(radio_h radio, int *frequency)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+
+ int freq;
+ int ret = mm_radio_get_frequency(handle->mm_handle, &freq);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ *frequency = freq;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_get_signal_strength(radio_h radio, int *strength)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+
+ int _strength;
+ int ret = mm_radio_get_signal_strength(handle->mm_handle, &_strength);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ *strength = _strength;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_READY);
+
+ if(callback!=NULL)
+ {
+ __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO,radio,callback,user_data);
+ }
+ else
+ {
+ __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO,radio);
+ }
+
+ int ret = mm_radio_scan_start(handle->mm_handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->state = RADIO_STATE_SCANNING;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+ RADIO_STATE_CHECK(handle,RADIO_STATE_SCANNING);
+
+ if(callback!=NULL)
+ {
+ __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP,radio,callback,user_data);
+ }
+ else
+ {
+ __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP,radio);
+ }
+
+ int ret = mm_radio_scan_stop(handle->mm_handle);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->state = RADIO_STATE_READY;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+
+int radio_set_mute(radio_h radio, bool muted)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ radio_s * handle = (radio_s *) radio;
+
+ int ret = mm_radio_set_mute(handle->mm_handle, muted);
+ if(ret != MM_ERROR_NONE)
+ {
+ return __convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ else
+ {
+ handle->mute = muted;
+ return RADIO_ERROR_NONE;
+ }
+}
+
+int radio_is_muted(radio_h radio, bool *muted)
+{
+ RADIO_INSTANCE_CHECK(radio);
+ RADIO_NULL_ARG_CHECK(muted);
+ radio_s * handle = (radio_s *) radio;
+ *muted = handle->mute;
+ return RADIO_ERROR_NONE;
+}
+
+int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data)
+{
+ return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,radio,callback,user_data);
+}
+
+int radio_unset_scan_completed_cb(radio_h radio)
+{
+ return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,radio);
+}
+
+int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data)
+{
+ return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio,callback,user_data);
+}
+
+int radio_unset_interrupted_cb(radio_h radio)
+{
+ return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio);
+}