diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:50:00 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:50:00 +0900 |
commit | e7a65f90ae954bfb147a2d70a626e476805372d7 (patch) | |
tree | 4dc61cd55a81177c264e94892e8b891d31e47e74 /src/include | |
parent | b3ad876ff93aa446f5404091fc38e905cdd92bfa (diff) | |
download | libmm-radio-e7a65f90ae954bfb147a2d70a626e476805372d7.tar.gz libmm-radio-e7a65f90ae954bfb147a2d70a626e476805372d7.tar.bz2 libmm-radio-e7a65f90ae954bfb147a2d70a626e476805372d7.zip |
Tizen 2.1 base
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/mm_radio.h | 3454 | ||||
-rw-r--r-- | src/include/mm_radio_asm.h | 50 | ||||
-rw-r--r-- | src/include/mm_radio_priv.h | 234 | ||||
-rw-r--r-- | src/include/mm_radio_utils.h | 105 |
4 files changed, 3843 insertions, 0 deletions
diff --git a/src/include/mm_radio.h b/src/include/mm_radio.h new file mode 100644 index 0000000..dba7d56 --- /dev/null +++ b/src/include/mm_radio.h @@ -0,0 +1,3454 @@ +/* + * libmm-radio + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com> + * + * 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 __MM_RADIO_H__ +#define __MM_RADIO_H__ + +#include <mm_types.h> +#include <mm_message.h> +#include <mm_error.h> + +#ifdef __cplusplus + extern "C" { +#endif + +/** + @addtogroup RADIO + @{ + + @par + This part describes the APIs with respect to play radio + + */ + + +/** + * Enumerations of radio state. + */ +typedef enum { + MM_RADIO_STATE_NULL = 1, /**< Radio is created, but not realized yet */ + MM_RADIO_STATE_READY, /**< Radio is ready to play */ + MM_RADIO_STATE_PLAYING, /**< Radio is now playing radio */ + MM_RADIO_STATE_SCANNING, /**< Radio is now scanning frequency */ + MM_RADIO_STATE_NUM, /**< Number of radio states */ +} MMRadioStateType; + +/** + * Enumerations of seeking direction. + */ +typedef enum { + MM_RADIO_SEEK_UP, /**< Seek upward */ + MM_RADIO_SEEK_DOWN, /**< Seek downward */ + MM_RADIO_SEEK_NUM /**< Number of seeking direction */ +} MMRadioSeekDirectionType; + +/** + * Enumerations of radio region country + * Region settings are according to radio standards, not real geographic regions. + * MM_RADIO_REGION_GROUP_1 : Notrh America, South America, South Korea, Taiwan, Australia + * frequency details : 88.1 - 108MHz, 75uS de-emphasis + * + * MM_RADIO_REGION_GROUP_2 : China, Europe, Africa, Middle East, Hong Kong, India, Indonesia, Russia, Singapore + * frequency details : 87.5 - 108MHz, 50uS de-emphasis + * + * MM_RADIO_REGION_GROUP_3 : Japan alone currenlty + * frequency details : 76.1 - 89.9MHz, 50uS de-emphasis + */ +typedef enum { + MM_RADIO_REGION_GROUP_NONE = 0, /**< Region None */ + MM_RADIO_REGION_GROUP_USA, /**< Region USA group */ + MM_RADIO_REGION_GROUP_EUROPE, /**< Region EUROPE group */ + MM_RADIO_REGION_GROUP_JAPAN, /**< Region Japan group */ +} MMRadioRegionType; + +/** + * This function creates a radio handle. \n + * So, application can make radio instance and initializes it. + * + * + * @param hradio [out] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post MM_RADIO_STATE_NULL + * @remark None + * @see mm_radio_destroy mm_radio_realize mm_radio_unrealize mm_radio_start mm_radio_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_create(MMHandleType *hradio); + +/** + * This function deletes radio handle. \n + * It closes radio device and releases all resources allocated. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre Application can use this API at any state. + * @post None + * @remark None + * @see mm_radio_create mm_radio_realize mm_radio_unrealize mm_radio_start mm_radio_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_destroy(MMHandleType hradio); + +/** + * This function opens radio device and ready to tune. \n + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_NULL + * @post MM_RADIO_STATE_READY + * @remark None + * @see mm_radio_create mm_radio_destroy mm_radio_unrealize mm_radio_start mm_radio_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_realize(MMHandleType hradio); + +/** + * This function mutes tuner and closes the radio device. + * And, application can destroy radio directly without this API. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_READY + * @post MM_RADIO_STATE_NULL + * @remark None + * @see mm_radio_create mm_radio_destroy mm_radio_realize mm_radio_start mm_radio_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_unrealize(MMHandleType hradio); + +/** + * This function sets the callback function for receiving messages from radio. + * + * @param hradio [in] Handle of radio. + * @param callback [in] Message callback function. + * @param user_param [in] User parameter which is passed to callback function. + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark None + * @see + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_set_message_callback(MMHandleType hradio, MMMessageCallback callback, void *user_param); + +/** + * This function gets the current state of radio. + * + * @param hradio [in] Handle of radio. + * @param state [out] Current state of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark None + * @see + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + * @endcode + */ +int mm_radio_get_state(MMHandleType hradio, MMRadioStateType *state); + +/** + * This function is to start playing radio. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_READY + * @post MM_RADIO_STATE_PLAYING + * @remark None + * @see mm_radio_create mm_radio_destroy mm_radio_realize mm_radio_unrealize mm_radio_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_start(MMHandleType hradio); + +/** + * This function is to stop playing radio. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_PLAYING + * @post MM_RADIO_STATE_READY + * @remark None + * @see mm_radio_create mm_radio_destroy mm_radio_realize mm_radio_unrealize mm_radio_start + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_stop(MMHandleType hradio); + +/** + * This function seeks the effective frequency of radio. The application get a valid frequency from current value. \n + * And, it can select direction to seek. + * MM_MESSAGE_RADIO_SEEK_START will be sent when this function is called. \n + * And if one valid frequency is found, MM_MESSAGE_RADIO_SEEK_FINISH will be sent. \n + * It doesn't support wrap_around to prevent looping when there is no any valid frequency. \n + * So, we will notice the limit of band as 87.5Mhz or 108Mhz. + * In this case, applicaion can take two scenario. + * One is to seek continually in the same direction. The other is to set previous frequency. + * + * @param hradio [in] Handle of radio. + * @param direction [in] Seeking direction. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_PLAYING + * @post MM_RADIO_STATE_PLAYING + * @remark None + * @see MM_MESSAGE_RADIO_SEEK_START MM_MESSAGE_RADIO_SEEK_FINISH + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_seek(MMHandleType hradio, MMRadioSeekDirectionType direction); + +/** + * This function sets the radio frequency with the desired one. + * + * @param hradio [in] Handle of radio. + * @param freq [in] Frequency to set. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_READY, MM_RADIO_STATE_PLAYING + * @post MM_RADIO_STATE_READY, MM_RADIO_STATE_PLAYING + * @remark None + * @see mm_radio_get_frequency + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_set_frequency(MMHandleType hradio, int freq); + +/** + * This function gets the current frequency of radio. + * + * @param hradio [in] Handle of radio. + * @param pFreq [out] Current frequency. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_READY, MM_RADIO_STATE_PLAYING + * @post MM_RADIO_STATE_READY, MM_RADIO_STATE_PLAYING + * @remark None + * @see mm_radio_set_frequency + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_get_frequency(MMHandleType hradio, int* pFreq); + +/** + * This function is to start for getting all effective frequencies. \n + * So, if a frequency is found, MM_MESSAGE_RADIO_SCAN_INFO will be posted with frequency information. + * If there is no frequency, we will post MM_MESSAGE_RADIO_SCAN_FINISH. + * And then, the radio state will be changed as MM_RADIO_STATE_READY. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_READY + * @post MM_RADIO_STATE_SCANNING + * @remark None + * @see mm_radio_scan_stop + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_scan_start(MMHandleType hradio); + +/** + * This function is to stop for getting all the effective frequencies. \n + * So, application can use this API to stop in the middle of scanning. + * + * @param hradio [in] Handle of radio. + * + * @return This function returns zero on success, or negative value with errors + * @pre MM_RADIO_STATE_SCANNING + * @post MM_RADIO_STATE_READY + * @remark None + * @see mm_radio_scan_start + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 15 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_scan_stop(MMHandleType hradio); + +/** + * This function is to mute/unmute radio output. + * + * @param hradio [in] Handle of radio. + * @param muted [in] 0: unmute 1: mute + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark None + * @see + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[16] mm_radio_set_mute\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 16 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + case 16: + { + bool muted = 0; + printf("select one(0:UNMUTE/1:MUTE) : "); + scanf("%d", &muted); + RADIO_TEST__( mm_radio_set_mute(g_my_radio, muted); ) + } + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_set_mute(MMHandleType hradio, bool muted); +/** + * This function is get strength of radio signal. + * + * @param hradio [in] Handle of radio. + * @param value [in] signal strength + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark None + * @see + * @par Example + * @code +#include <stdlib.h> +#include <stdio.h> +#include <mm_radio.h> + +#define RADIO_TEST__(x_test) \ + ret = x_test \ + if ( ! ret ) \ + { \ + printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ + } \ + else \ + { \ + printf("FAIL : %s ERR-CODE : %d -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ + } + +static MMHandleType g_my_radio = 0; + +int __menu(void) +{ + int menu_item = 0; + + printf("---------------------------------------------------------\n"); + printf("mm-radio rt api test. try now!\n"); + printf("---------------------------------------------------------\n"); + printf("[1] mm_radio_create\n"); + printf("[2] mm_radio_destroy\n"); + printf("[3] mm_radio_realize\n"); + printf("[4] mm_radio_unrealize\n"); + printf("[7] mm_radio_get_state\n"); + printf("[8] mm_radio_start\n"); + printf("[9] mm_radio_stop\n"); + printf("[10] mm_radio_seek\n"); + printf("[11] mm_radio_set_frequency\n"); + printf("[12] mm_radio_get_frequency\n"); + printf("[13] mm_radio_scan_start\n"); + printf("[14] mm_radio_scan_stop\n"); + printf("[16] mm_radio_set_mute\n"); + printf("[0] quit\n"); + printf("---------------------------------------------------------\n"); + printf("choose one : "); + scanf("%d", &menu_item); + + if ( menu_item > 16 ) + menu_item = -1; + + return menu_item; +} + +int __msg_rt_callback(int message, void *pParam, void *user_param) +{ + MMMessageParamType* param = (MMMessageParamType*)pParam; + int ret = 0; + + printf("incomming message : %d\n", message); + + switch(message) + { + case MM_MESSAGE_STATE_CHANGED: + + printf("MM_MESSAGE_STATE_CHANGED: current : %d old : %d\n" + , param->state.current, param->state.previous); + break; + case MM_MESSAGE_RADIO_SCAN_START: + printf("MM_MESSAGE_RADIO_SCAN_START\n"); + break; + case MM_MESSAGE_RADIO_SCAN_INFO: + assert(param); + printf("MM_MESSAGE_RADIO_SCAN_INFO : freq : %d\n", param->radio_scan.frequency); + break; + case MM_MESSAGE_RADIO_SCAN_STOP: + printf("MM_MESSAGE_RADIO_SCAN_STOP\n"); + break; + case MM_MESSAGE_RADIO_SCAN_FINISH: + printf("MM_MESSAGE_RADIO_SCAN_FINISHED\n"); + break; + case MM_MESSAGE_RADIO_SEEK_START: + printf("MM_MESSAGE_RADIO_SEEK_START\n"); + break; + case MM_MESSAGE_RADIO_SEEK_FINISH: + printf("MM_MESSAGE_RADIO_SEEK_FINISHED : freq : %d\n", param->radio_scan.frequency); + break; + default: + printf("ERROR : unknown message received!\n"); + break; + } + + return true; +} + +void __call_api( int choosen ) +{ + int ret = MM_ERROR_NONE; + + switch( choosen ) + { + case 1: + { + RADIO_TEST__( mm_radio_create( &g_my_radio ); ) + RADIO_TEST__( mm_radio_set_message_callback( g_my_radio, __msg_rt_callback, &g_my_radio); ) + } + break; + + case 2: + { + RADIO_TEST__( mm_radio_destroy( g_my_radio ); ) + g_my_radio = 0; + } + break; + + case 3: + { + RADIO_TEST__( mm_radio_realize(g_my_radio ); ) + } + break; + + case 4: + { + RADIO_TEST__( mm_radio_unrealize(g_my_radio ); ) + } + break; + + case 7: + { + MMRadioStateType state = 0; + RADIO_TEST__( mm_radio_get_state(g_my_radio, &state); ) + + printf("state : %d\n", state); + } + break; + + case 8: + { + RADIO_TEST__( mm_radio_start(g_my_radio); ) + } + break; + + case 9: + { + RADIO_TEST__( mm_radio_stop(g_my_radio); ) + } + break; + + case 10: + { + MMRadioSeekDirectionType direction = 0; + printf("input seek direction(0:UP/1:DOWN) : "); + scanf("%d", &direction); + RADIO_TEST__( mm_radio_seek(g_my_radio, direction); ) + } + break; + + case 11: + { + int freq = 0; + printf("input freq : "); + scanf("%d", &freq); + RADIO_TEST__( mm_radio_set_frequency(g_my_radio, freq); ) + } + break; + + case 12: + { + int freq = 0; + RADIO_TEST__( mm_radio_get_frequency(g_my_radio, &freq ); ) + + printf("freq : %d\n", freq); + } + break; + + case 13: + { + RADIO_TEST__( mm_radio_scan_start(g_my_radio); ) + } + break; + + case 14: + { + RADIO_TEST__( mm_radio_scan_stop(g_my_radio); ) + } + break; + + case 16: + { + bool muted = 0; + printf("select one(0:UNMUTE/1:MUTE) : "); + scanf("%d", &muted); + RADIO_TEST__( mm_radio_set_mute(g_my_radio, muted); ) + } + + default: + break; + } +} + +int main(int argc, char **argv) +{ + while(1) + { + char key = 0; + int choosen = 0; + + choosen = __menu(); + + if ( choosen == -1) + continue; + + if ( choosen == 0 ) + break; + + __call_api( choosen ); + } +} + + * @endcode + */ +int mm_radio_get_signal_strength(MMHandleType hradio, int *value); + +/** + * This function is to get type of radio region. + * + * @param hradio [in] Handle of radio. + * @param type [out] type of current region + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark None + * @see mm_radio_get_region_frequency_range() + */ +int mm_radio_get_region_type(MMHandleType hradio, MMRadioRegionType *type); + +/** + * This function is to get range of radio frequency. + * + * @param hradio [in] Handle of radio. + * @param min [out] min frequency value + * @param max [out] max frequency value + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @remark The unit of frequency is KHz. + * @see mm_radio_get_region_type() + */ +int mm_radio_get_region_frequency_range(MMHandleType hradio, unsigned int *min, unsigned int *max); + +/** + @} + */ + + +#ifdef __cplusplus + } +#endif + +#endif /* __MM_RADIO_H__ */ diff --git a/src/include/mm_radio_asm.h b/src/include/mm_radio_asm.h new file mode 100644 index 0000000..c8d1c93 --- /dev/null +++ b/src/include/mm_radio_asm.h @@ -0,0 +1,50 @@ +/* + * libmm-radio + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com> + * + * 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 MM_RADIO_ASM_H_ +#define MM_RADIO_ASM_H_ + +#include <mm_types.h> +#include <mm_error.h> + +#include <mm_session.h> +#include <mm_session_private.h> +#include <audio-session-manager.h> + +enum { + MMRADIO_ASM_CB_NONE, + MMRADIO_ASM_CB_POSTMSG, + MMRADIO_ASM_CB_SKIP_POSTMSG +}; +typedef struct { + int handle; + int pid; + int by_asm_cb; + int event_src; + ASM_sound_states_t state; +} MMRadioASM; + +/* returns allocated handle */ +int mmradio_asm_register(MMRadioASM* sm, ASM_sound_cb_t callback, void* param); +int mmradio_asm_deregister(MMRadioASM* sm); +int mmradio_asm_set_state(MMRadioASM* sm, ASM_sound_states_t state, ASM_resource_t resource); + +#endif /* MM_RADIO_ASM_H_ */ diff --git a/src/include/mm_radio_priv.h b/src/include/mm_radio_priv.h new file mode 100644 index 0000000..04c14b8 --- /dev/null +++ b/src/include/mm_radio_priv.h @@ -0,0 +1,234 @@ +/* + * libmm-radio + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com> + * + * 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 __MM_Radio_INTERNAL_H__ +#define __MM_Radio_INTERNAL_H__ + +/*=========================================================================================== + INCLUDE FILES +========================================================================================== */ +#include <stdio.h> +#include <stdbool.h> +#include <unistd.h> +#include <malloc.h> +#include <pthread.h> +#include <signal.h> + +#include <mm_types.h> +#include <mm_message.h> + +#include "mm_radio_asm.h" +#include "mm_radio.h" +#include "mm_radio_utils.h" +#include <linux/videodev2.h> + +#include <gst/gst.h> +#include <gst/gstbuffer.h> + +#ifdef __cplusplus + extern "C" { +#endif + +/*=========================================================================================== + GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE +========================================================================================== */ + +/*--------------------------------------------------------------------------- + GLOBAL #defines: +---------------------------------------------------------------------------*/ +#define SAMPLEDELAY 15000 + +/* si470x dependent define */ +#define SYSCONFIG1 4 /* System Configuration 1 */ +#define SYSCONFIG1_RDS 0x1000 /* bits 12..12: RDS Enable */ +#define SYSCONFIG1_RDS_OFFSET 12 /* bits 12..12: RDS Enable Offset */ + +#define SYSCONFIG2 5 /* System Configuration 2 */ +#define SYSCONFIG2_SEEKTH 0xff00 /* bits 15..08: RSSI Seek Threshold */ +#define SYSCONFIG2_SEEKTH_OFFSET 8 /* bits 15..08: RSSI Seek Threshold Offset */ + +#define SYSCONFIG3 6 /* System Configuration 3 */ +#define SYSCONFIG3_SKSNR 0x00f0 /* bits 07..04: Seek SNR Threshold */ +#define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */ +#define SYSCONFIG3_SKSNR_OFFSET 4 /* bits 07..04: Seek SNR Threshold Offset */ +#define SYSCONFIG3_SKCNT_OFFSET 0 /* bits 03..00: Seek FM Impulse Detection Threshold Offset */ + +#define DEFAULT_CHIP_MODEL "radio-si470x" + +/*--------------------------------------------------------------------------- + GLOBAL CONSTANT DEFINITIONS: +---------------------------------------------------------------------------*/ +typedef enum +{ + MMRADIO_COMMAND_CREATE = 0, + MMRADIO_COMMAND_DESTROY, + MMRADIO_COMMAND_REALIZE, + MMRADIO_COMMAND_UNREALIZE, + MMRADIO_COMMAND_START, + MMRADIO_COMMAND_STOP, + MMRADIO_COMMAND_START_SCAN, + MMRADIO_COMMAND_STOP_SCAN, + MMRADIO_COMMAND_SET_FREQ, + MMRADIO_COMMAND_GET_FREQ, + MMRADIO_COMMAND_MUTE, + MMRADIO_COMMAND_UNMUTE, + MMRADIO_COMMAND_SEEK, + MMRADIO_COMMAND_SET_REGION, + MMRADIO_COMMAND_GET_REGION, + MMRADIO_COMMAND_NUM +} MMRadioCommand; + +/* max and mix frequency types, KHz */ +typedef enum +{ + MM_RADIO_FREQ_NONE = 0, + /* min band types */ + MM_RADIO_FREQ_MIN_76100_KHZ = 76100, + MM_RADIO_FREQ_MIN_87500_KHZ = 87500, + MM_RADIO_FREQ_MIN_88100_KHZ = 88100, + /* max band types */ + MM_RADIO_FREQ_MAX_89900_KHZ = 89900, + MM_RADIO_FREQ_MAX_108000_KHZ = 108000, +}MMRadioFreqTypes; + +/* de-emphasis types */ +typedef enum +{ + MM_RADIO_DEEMPHASIS_NONE = 0, + MM_RADIO_DEEMPHASIS_50_US, + MM_RADIO_DEEMPHASIS_75_US, +}MMRadioDeemphasis; + +/* radio region settings */ +typedef struct +{ + MMRadioRegionType country; + MMRadioDeemphasis deemphasis; // unit : us + MMRadioFreqTypes band_min; // <- freq. range, unit : KHz + MMRadioFreqTypes band_max; // -> + //int channel_spacing; // TBD +}MMRadioRegion_t; + +/*--------------------------------------------------------------------------- + GLOBAL DATA TYPE DEFINITIONS: +---------------------------------------------------------------------------*/ +#define USE_GST_PIPELINE + +#ifdef USE_GST_PIPELINE +typedef struct _mm_radio_gstreamer_s +{ + GMainLoop *loop; + GstElement *pipeline; + GstElement *avsysaudiosrc; + GstElement *queue2; + GstElement *avsysaudiosink; + GstBuffer *output_buffer; +} mm_radio_gstreamer_s; +#endif + +typedef struct { + /* radio state */ + int current_state; + int old_state; + int pending_state; + + int cmd; + + /* command lock */ + pthread_mutex_t cmd_lock; + + /* radio attributes */ + MMHandleType* attrs; + + /* message callback */ + MMMessageCallback msg_cb; + void* msg_cb_param; + + /* radio device fd */ + int radio_fd; + + /* device control */ + struct v4l2_capability vc; + struct v4l2_tuner vt; + struct v4l2_control vctrl; + struct v4l2_frequency vf; + + /* hw debug */ + struct v4l2_dbg_register reg; + + /* scan */ + pthread_t scan_thread; + bool stop_scan; + + /* seek */ + pthread_t seek_thread; + int prev_seek_freq; + MMRadioSeekDirectionType seek_direction; + + /* ASM */ + MMRadioASM sm; + + int freq; +#ifdef USE_GST_PIPELINE + mm_radio_gstreamer_s* pGstreamer_s; +#endif + + /* region settings */ + MMRadioRegion_t region_setting; +} mm_radio_t; + +/*=========================================================================================== + GLOBAL FUNCTION PROTOTYPES +========================================================================================== */ +int _mmradio_create_radio(mm_radio_t* radio); +int _mmradio_destroy(mm_radio_t* radio); +int _mmradio_realize(mm_radio_t* radio); +int _mmradio_unrealize(mm_radio_t* radio); +int _mmradio_set_message_callback(mm_radio_t* radio, MMMessageCallback callback, void *user_param); +int _mmradio_get_state(mm_radio_t* radio, int* pState); +int _mmradio_set_frequency(mm_radio_t* radio, int freq); +int _mmradio_get_frequency(mm_radio_t* radio, int* pFreq); +int _mmradio_mute(mm_radio_t* radio); +int _mmradio_unmute(mm_radio_t* radio); +int _mmradio_start(mm_radio_t* radio); +int _mmradio_stop(mm_radio_t* radio); +int _mmradio_seek(mm_radio_t* radio, MMRadioSeekDirectionType direction); +int _mmradio_start_scan(mm_radio_t* radio); +int _mmradio_stop_scan(mm_radio_t* radio); +#ifdef USE_GST_PIPELINE +int _mmradio_realize_pipeline( mm_radio_t* radio); +int _mmradio_start_pipeline(mm_radio_t* radio); +int _mmradio_stop_pipeline( mm_radio_t* radio); +int _mmradio_destroy_pipeline(mm_radio_t* radio); +#endif +int _mmradio_apply_region(mm_radio_t*radio, MMRadioRegionType region, bool update); +int _mmradio_get_region_type(mm_radio_t*radio, MMRadioRegionType *type); +int _mmradio_get_region_frequency_range(mm_radio_t* radio, uint *min_freq, uint *max_freq); +#if 0 +int mmradio_set_attrs(mm_radio_t* radio, MMRadioAttrsType type, MMHandleType attrs); +MMHandleType mmradio_get_attrs(mm_radio_t* radio, MMRadioAttrsType type); +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* __MM_Radio_INTERNAL_H__ */ diff --git a/src/include/mm_radio_utils.h b/src/include/mm_radio_utils.h new file mode 100644 index 0000000..13c3765 --- /dev/null +++ b/src/include/mm_radio_utils.h @@ -0,0 +1,105 @@ +/* + * libmm-radio + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com> + * + * 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 __MM_RADIO_UTILS_H__ +#define __MM_RADIO_UTILS_H__ + +#include <assert.h> +#include <mm_types.h> +#include <mm_error.h> +#include <mm_message.h> + +/* radio log */ +#define MMRADIO_LOG_FENTER debug_fenter +#define MMRADIO_LOG_FLEAVE debug_fleave +#define MMRADIO_LOG_DEBUG debug_log +#define MMRADIO_LOG_ERROR debug_error +#define MMRADIO_LOG_WARNING debug_warning +#define MMRADIO_LOG_CRITICAL debug_critical + +/* general */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + +#define MMRADIO_MAX_INT (2147483647) + +#define MMRADIO_FREEIF(x) \ +if ( x ) \ + free( x ); \ +x = NULL; + +#define MMRADIO_CHECK_INSTANCE( x_radio ) \ +if ( ! x_radio ) \ +{ \ + debug_error("radio instance is NULL\n"); \ + return MM_ERROR_RADIO_NOT_INITIALIZED; \ +} + +#define MMRADIO_CHECK_DEVICE_STATE( x_radio ) \ +if ( x_radio->radio_fd < 0 ) \ +{ \ + debug_error("not available radio device\n"); \ + return MM_ERROR_RADIO_NOT_INITIALIZED;\ +} + +/* command locking for multithreading */ +#define MMRADIO_CMD_LOCK(x_radio) pthread_mutex_lock( &((mm_radio_t*)x_radio)->cmd_lock ) +#define MMRADIO_CMD_UNLOCK(x_radio) pthread_mutex_unlock( &((mm_radio_t*)x_radio)->cmd_lock ) + +/* message posting */ +#define MMRADIO_POST_MSG( x_radio, x_msgtype, x_msg_param ) \ +debug_log("posting %s to application\n", #x_msgtype); \ +__mmradio_post_message(x_radio, x_msgtype, x_msg_param); + +/* setting radio state */ +#define MMRADIO_SET_STATE( x_radio, x_state ) \ +debug_log("setting mm-radio state to %d\n", x_state); \ +__mmradio_set_state(x_radio, x_state); + +/* state */ +#define MMRADIO_CHECK_STATE_RETURN_IF_FAIL( x_radio, x_command ) \ +debug_log("checking radio state before doing %s\n", #x_command); \ +switch ( __mmradio_check_state(x_radio, x_command) ) \ +{ \ + case MM_ERROR_RADIO_INVALID_STATE: \ + return MM_ERROR_RADIO_INVALID_STATE; \ + break; \ + /* NOTE : for robustness of mmfw. we won't treat it as an error */ \ + case MM_ERROR_RADIO_NO_OP: \ + return MM_ERROR_NONE; \ + break; \ + default: \ + break; \ +} + +#define MMRADIO_CHECK_RETURN_IF_FAIL( x_ret, x_msg ) \ +do \ +{ \ + if( x_ret < 0 ) \ + { \ + debug_error("%s error\n", x_msg);\ + return x_ret; \ + } \ +} while( 0 ) ; + +#endif + |