From: Gilbok Lee Date: Thu, 10 Dec 2015 06:41:36 +0000 (+0900) Subject: Apply Tizen coding rule and add doc X-Git-Tag: submit/tizen/20151211.082233^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F53907%2F2;p=platform%2Fcore%2Fapi%2Fradio.git Apply Tizen coding rule and add doc Change-Id: I1c5d96598edaf1cea5777a222ddac8d415c0d7ac Signed-off-by: Gilbok Lee --- diff --git a/packaging/capi-media-radio.spec b/packaging/capi-media-radio.spec index 606224d..8a77873 100644 --- a/packaging/capi-media-radio.spec +++ b/packaging/capi-media-radio.spec @@ -1,7 +1,7 @@ Name: capi-media-radio Summary: A Radio library in Tizen Native API Version: 0.1.2 -Release: 10 +Release: 11 Group: API/C API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/radio.c b/src/radio.c index c220f38..9e5313c 100755 --- a/src/radio.c +++ b/src/radio.c @@ -31,21 +31,26 @@ /* * 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_CHECK_CONDITION(condition, error, msg) \ + do { \ + if (condition) { \ + } else { \ + LOGE("[%s] %s(0x%08x)", (char *)__FUNCTION__, msg, error); \ + return error; \ + } \ + } while (0) #define RADIO_INSTANCE_CHECK(radio) \ - RADIO_CHECK_CONDITION(radio != NULL, RADIO_ERROR_INVALID_PARAMETER,"RADIO_ERROR_INVALID_PARAMETER") + 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_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") + RADIO_CHECK_CONDITION(arg != NULL, RADIO_ERROR_INVALID_PARAMETER, "RADIO_ERROR_INVALID_PARAMETER") #define RADIO_SUPPORT_CHECK(arg) \ - RADIO_CHECK_CONDITION(arg != false, RADIO_ERROR_NOT_SUPPORTED,"RADIO_ERROR_NOT_SUPPORTED") + RADIO_CHECK_CONDITION(arg != false, RADIO_ERROR_NOT_SUPPORTED, "RADIO_ERROR_NOT_SUPPORTED") /* * Internal Implementation @@ -53,56 +58,55 @@ static int __convert_error_code(int code, char *func_name) { int ret = RADIO_ERROR_NONE; - char* msg="RADIO_ERROR_NONE"; + char *msg = "RADIO_ERROR_NONE"; LOGI("[%s] Enter code :%x", __func__, code); - 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: - case MM_ERROR_RADIO_INVALID_STATE: - ret = RADIO_ERROR_INVALID_STATE; - msg = "RADIO_ERROR_INVALID_STATE"; - break; - case MM_ERROR_COMMON_INVALID_ARGUMENT: - case MM_ERROR_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: - ret= RADIO_ERROR_INVALID_OPERATION; - msg = "RADIO_ERROR_INVALID_OPERATION"; - break; - case MM_ERROR_RADIO_DEVICE_NOT_FOUND: - ret = RADIO_ERROR_NOT_SUPPORTED; - msg = "RADIO_ERROR_NOT_SUPPORTED"; - break; - case MM_ERROR_RADIO_NO_ANTENNA: - ret = RADIO_ERROR_NO_ANTENNA; - msg = "RADIO_ERROR_NO_ANTENNA"; - break; - case MM_ERROR_RADIO_DEVICE_NOT_OPENED: - default : - ret= RADIO_ERROR_PERMISSION_DENIED; - msg = "RADIO_ERROR_PERMISSION_DENIED"; - } - LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code); + 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: + case MM_ERROR_RADIO_INVALID_STATE: + ret = RADIO_ERROR_INVALID_STATE; + msg = "RADIO_ERROR_INVALID_STATE"; + break; + case MM_ERROR_COMMON_INVALID_ARGUMENT: + case MM_ERROR_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: + ret = RADIO_ERROR_INVALID_OPERATION; + msg = "RADIO_ERROR_INVALID_OPERATION"; + break; + case MM_ERROR_RADIO_DEVICE_NOT_FOUND: + ret = RADIO_ERROR_NOT_SUPPORTED; + msg = "RADIO_ERROR_NOT_SUPPORTED"; + break; + case MM_ERROR_RADIO_NO_ANTENNA: + ret = RADIO_ERROR_NO_ANTENNA; + msg = "RADIO_ERROR_NO_ANTENNA"; + break; + case MM_ERROR_RADIO_DEVICE_NOT_OPENED: + default: + ret = RADIO_ERROR_PERMISSION_DENIED; + msg = "RADIO_ERROR_PERMISSION_DENIED"; + } + LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code); return ret; } @@ -110,145 +114,129 @@ static radio_state_e __convert_radio_state(MMRadioStateType state) { int converted_state = RADIO_STATE_READY; LOGI("[%s] Enter state: %d", __func__, state); - 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; + 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; } LOGI("[%s] Leave converted_state: %d", __func__, converted_state); return converted_state; } - static radio_interrupted_code_e __convert_interrupted_code(int code) { LOGI("[%s] Enter code: %d", __func__, code); radio_interrupted_code_e ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT; - switch(code) - { - case MM_MSG_CODE_INTERRUPTED_BY_CALL_END: - case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END: - case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END: - case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_END: - ret = RADIO_INTERRUPTED_COMPLETED; - break; - case MM_MSG_CODE_INTERRUPTED_BY_MEDIA: - case MM_MSG_CODE_INTERRUPTED_BY_OTHER_PLAYER_APP: - ret = RADIO_INTERRUPTED_BY_MEDIA; - break; - case MM_MSG_CODE_INTERRUPTED_BY_CALL_START: - ret = RADIO_INTERRUPTED_BY_CALL; - break; - case MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG: - ret = RADIO_INTERRUPTED_BY_EARJACK_UNPLUG; - break; - case MM_MSG_CODE_INTERRUPTED_BY_ALARM_START: - ret = RADIO_INTERRUPTED_BY_ALARM; - break; - case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_START: - ret = RADIO_INTERRUPTED_BY_NOTIFICATION; - break; - case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START: - ret = RADIO_INTERRUPTED_BY_EMERGENCY; - break; - case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT: - default : - ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT; - break; - } - LOGE("[%s] interrupted code(%d) => ret(%d)",__FUNCTION__,code, ret); + switch (code) { + case MM_MSG_CODE_INTERRUPTED_BY_CALL_END: + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END: + case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END: + case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_END: + ret = RADIO_INTERRUPTED_COMPLETED; + break; + case MM_MSG_CODE_INTERRUPTED_BY_MEDIA: + case MM_MSG_CODE_INTERRUPTED_BY_OTHER_PLAYER_APP: + ret = RADIO_INTERRUPTED_BY_MEDIA; + break; + case MM_MSG_CODE_INTERRUPTED_BY_CALL_START: + ret = RADIO_INTERRUPTED_BY_CALL; + break; + case MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG: + ret = RADIO_INTERRUPTED_BY_EARJACK_UNPLUG; + break; + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_START: + ret = RADIO_INTERRUPTED_BY_ALARM; + break; + case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_START: + ret = RADIO_INTERRUPTED_BY_NOTIFICATION; + break; + case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START: + ret = RADIO_INTERRUPTED_BY_EMERGENCY; + break; + case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT: + default: + ret = RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT; + break; + } + LOGE("[%s] interrupted code(%d) => ret(%d)", __FUNCTION__, code, ret); return ret; } -static int __set_callback(_radio_event_e type, radio_h radio, void* callback, void *user_data) +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; + radio_s *handle = (radio_s *)radio; handle->user_cb[type] = callback; handle->user_data[type] = user_data; - LOGI("[%s] Event type : %d ",__FUNCTION__, type); + 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; + radio_s *handle = (radio_s *)radio; handle->user_cb[type] = NULL; handle->user_data[type] = NULL; - LOGI("[%s] Event type : %d ",__FUNCTION__, type); + 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])(__convert_interrupted_code(msg->code),handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]); - } - break; - case MM_MESSAGE_READY_TO_RESUME: - if( handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT] ) - { - ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_COMPLETED,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; + 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])(__convert_interrupted_code(msg->code), handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]); + break; + case MM_MESSAGE_READY_TO_RESUME: + if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT]) + ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_COMPLETED, 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; } @@ -260,20 +248,15 @@ static int __radio_check_system_info_feature_supported() nRetVal = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &bValue); - if ( nRetVal != SYSTEM_INFO_ERROR_NONE ) - { + if (nRetVal != SYSTEM_INFO_ERROR_NONE) { LOGE("[%s] SYSTEM_INFO_ERROR : ", __FUNCTION__); return false; } - if ( false == bValue ) - { + if (false == bValue) LOGI("system_info_get_platform_bool returned Unsupported feature capability\n"); - } else - { LOGI("system_info_get_platform_bool returned Supported status feature\n"); - } return bValue; } @@ -286,37 +269,31 @@ int radio_create(radio_h *radio) LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle; + 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); + 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) - { + if (ret != MM_ERROR_NONE) { free(handle); - handle=NULL; - return __convert_error_code(ret,(char*)__FUNCTION__); - } - else - { + handle = NULL; + return __convert_error_code(ret, (char *)__FUNCTION__); + } 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_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__); - } + if (ret != MM_ERROR_NONE) + return __convert_error_code(ret, (char *)__FUNCTION__); + handle->state = RADIO_STATE_READY; handle->mute = FALSE; return RADIO_ERROR_NONE; @@ -328,45 +305,37 @@ int radio_destroy(radio_h radio) LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) 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); - } + 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) - { - return __convert_error_code(ret,(char*)__FUNCTION__); - } - else - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { free(handle); - handle= NULL; + handle = NULL; return RADIO_ERROR_NONE; } } -int radio_get_state(radio_h radio, radio_state_e *state) +int radio_get_state(radio_h radio, radio_state_e *state) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); RADIO_NULL_ARG_CHECK(state); - radio_s * handle = (radio_s *) radio; + 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) - { + if (ret != MM_ERROR_NONE) { *state = handle->state; - return __convert_error_code(ret,(char*)__FUNCTION__); - } - else - { - handle->state = __convert_radio_state(currentStat); + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { + handle->state = __convert_radio_state(currentStat); *state = handle->state; return RADIO_ERROR_NONE; } @@ -377,16 +346,13 @@ int radio_start(radio_h radio) LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_READY); + 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 - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { handle->state = RADIO_STATE_PLAYING; return RADIO_ERROR_NONE; } @@ -397,75 +363,56 @@ int radio_stop(radio_h radio) LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING); + 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 - { + 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 ) +int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING); + 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); - } + if (callback != NULL) + __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data); else - { - __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio); - } + __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__); - } + 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 ) +int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_PLAYING); + 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); - } + if (callback != NULL) + __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data); else - { - __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH,radio); - } + __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__); - } + 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) @@ -473,22 +420,17 @@ int radio_set_frequency(radio_h radio, int frequency) LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); 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); + 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 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__); - } + 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) @@ -497,16 +439,13 @@ int radio_get_frequency(radio_h radio, int *frequency) RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); RADIO_NULL_ARG_CHECK(frequency); - radio_s * handle = (radio_s *) 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 - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { *frequency = freq; return RADIO_ERROR_NONE; } @@ -518,16 +457,13 @@ int radio_get_signal_strength(radio_h radio, int *strength) RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); RADIO_NULL_ARG_CHECK(strength); - radio_s * handle = (radio_s *) 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 - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { *strength = _strength; return RADIO_ERROR_NONE; } @@ -538,25 +474,18 @@ int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_d LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_READY); + 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); - } + if (callback != NULL) + __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio, callback, user_data); else - { - __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO,radio); - } + __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 - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { handle->state = RADIO_STATE_SCANNING; return RADIO_ERROR_NONE; } @@ -567,45 +496,34 @@ int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_da LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; - RADIO_STATE_CHECK(handle,RADIO_STATE_SCANNING); + 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); - } + if (callback != NULL) + __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio, callback, user_data); else - { - __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP,radio); - } + __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 - { + 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) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) 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 - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { handle->mute = muted; return RADIO_ERROR_NONE; } @@ -617,7 +535,7 @@ int radio_is_muted(radio_h radio, bool *muted) RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); RADIO_NULL_ARG_CHECK(muted); - radio_s * handle = (radio_s *) radio; + radio_s *handle = (radio_s *)radio; *muted = handle->mute; return RADIO_ERROR_NONE; } @@ -626,31 +544,30 @@ int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); - return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,radio,callback,user_data); + return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio, callback, user_data); } int radio_unset_scan_completed_cb(radio_h radio) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); - return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH,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) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); - return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio,callback,user_data); + return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio, callback, user_data); } int radio_unset_interrupted_cb(radio_h radio) { LOGI("[%s] Enter", __func__); RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); - return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT,radio); + return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio); } - int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq) { LOGI("[%s] Enter", __func__); @@ -658,18 +575,15 @@ int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq) RADIO_INSTANCE_CHECK(radio); RADIO_NULL_ARG_CHECK(min_freq); RADIO_NULL_ARG_CHECK(max_freq); - radio_s * handle = (radio_s *) radio; + radio_s *handle = (radio_s *)radio; unsigned int min = 0; unsigned int max = 0; int ret = mm_radio_get_region_frequency_range(handle->mm_handle, &min, &max); - if(ret != MM_ERROR_NONE) - { - return __convert_error_code(ret,(char*)__FUNCTION__); - } - else - { + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { *min_freq = min; *max_freq = max; return RADIO_ERROR_NONE; @@ -682,19 +596,12 @@ int radio_get_channel_spacing(radio_h radio, int *channel_spacing) RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); RADIO_INSTANCE_CHECK(radio); - radio_s * handle = (radio_s *) radio; + radio_s *handle = (radio_s *)radio; int ret = mm_radio_get_channel_spacing(handle->mm_handle, channel_spacing); - if(ret != MM_ERROR_NONE) - { - return __convert_error_code(ret,(char*)__FUNCTION__); - } + if (ret != MM_ERROR_NONE) + return __convert_error_code(ret, (char *)__FUNCTION__); else - { return RADIO_ERROR_NONE; - } } - - - diff --git a/test/radio_test.c b/test/radio_test.c index d7bfaa9..625145f 100755 --- a/test/radio_test.c +++ b/test/radio_test.c @@ -22,7 +22,6 @@ #include #include - #include "radio.h" #include "radio_test_type.h" #include @@ -31,7 +30,6 @@ #define MENU_ITEM_MAX 20 #define _MAX_INPUT_STRING_ 100 - /* test items...*/ int __test_radio_init(void); int __test_radio_listen_gorealra(void); @@ -42,80 +40,69 @@ int __test_repeat_whole(void); int __test_manual_api_calling(void); int __test_radio_hw_debug(void); - /* functions*/ static void __print_menu(void); static void __run_test(int key); int radio_rt_api_test(void); static int __menu(void); -static void __call_api( int choosen ); +static void __call_api(int choosen); void __radio_seek_completed_cb(int frequency, void *user_data); void __radio_scan_updated_cb(int freq, void *user_data); void __radio_scan_stop_cb(void *user_data); void __radio_set_scan_completed_cb(void *user_param); void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param); - - /* list of tests*/ -test_item_t g_tests[100] = -{ +test_item_t g_tests[100] = { /* menu string : short string to be displayed to menu - description : detailed description - test function : a pointer to a actual test function - 0 : to be filled with return value of test function + description : detailed description + test function : a pointer to a actual test function + 0 : to be filled with return value of test function */ { - "init test", - "check radio init function", - __test_radio_init, - 0 - }, + "init test", + "check radio init function", + __test_radio_init, + 0}, { - "listening gorealra", - "let's listen to the gorealra!", - __test_radio_listen_gorealra, - 0 - }, + "listening gorealra", + "let's listen to the gorealra!", + __test_radio_listen_gorealra, + 0}, { - "repeat_init_release", - "repeat init and release and check if it working and memory usage increment", - __test_repeat_init_release, - 0 - }, + "repeat_init_release", + "repeat init and release and check if it working and memory usage increment", + __test_repeat_init_release, + 0}, { - "repeat_start_stop", - "repeat start and stop and check if it working and memory usage increment", - __test_repeat_start_stop, - 0 - }, + "repeat_start_stop", + "repeat start and stop and check if it working and memory usage increment", + __test_repeat_start_stop, + 0}, { - "repeat_seek", - "repeat seek and check if it working and memory usage increment", - __test_repeat_seek, - 0 - }, + "repeat_seek", + "repeat seek and check if it working and memory usage increment", + __test_repeat_seek, + 0}, { - "repeat_whole", - "repeat whole radio sequence and check if it working and memory usage increment", - __test_repeat_whole, - 0 - }, + "repeat_whole", + "repeat whole radio sequence and check if it working and memory usage increment", + __test_repeat_whole, + 0}, { - "manual api calling test", - "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.", - __test_manual_api_calling, - 0 - }, + "manual api calling test", + "mapping each api to each test manu. just like other testsuite. try to reproduce the bugs with it.", + __test_manual_api_calling, + 0}, - /* add tests here*/ + /* add tests here */ /* NOTE : do not remove this last item */ {"end", "", NULL, 0}, @@ -134,14 +121,12 @@ int main(int argc, char **argv) do { key = getchar(); - if ( key >= '0' && key <= '9') - { - __run_test( key - '0' ); - } - }while ( key == '\n' ); - if(key == 'Q' || key == 'q') + if (key >= '0' && key <= '9') + __run_test(key - '0'); + } while (key == '\n'); + if (key == 'Q' || key == 'q') break; - }while(1); + } while (1); printf("radio test client finished\n"); @@ -155,10 +140,9 @@ void __print_menu(void) printf("\n\nFMRadio testing menu\n"); printf("------------------------------------------\n"); - for ( i = 0; g_tests[i].func; i++ ) - { - printf( "[%d] %s\n", i, g_tests[i].menu_string ); - } + for (i = 0; g_tests[i].func; i++) + printf("[%d] %s\n", i, g_tests[i].menu_string); + printf("[q] quit\n"); g_num_of_tests = i; @@ -172,32 +156,26 @@ void __run_test(int key) /* check index */ printf("#tests : %d key : %d\n", g_num_of_tests, key); - if ( key >= g_num_of_tests || key < 0 ) - { + if (key >= g_num_of_tests || key < 0) { printf("unassigned key has pressed : %d\n", key); return; } - /* display description*/ - printf( "excuting test : %s\n", g_tests[key].menu_string ); - printf( "description : %s\n", g_tests[key].description ); + /* display description */ + printf("excuting test : %s\n", g_tests[key].menu_string); + printf("description : %s\n", g_tests[key].description); - /* calling test function*/ + /* calling test function */ ret = g_tests[key].func(); - g_tests[key].result = ret; + g_tests[key].result = ret; - if ( ret ) - { - printf( "TEST FAILED. ret code : %d\n", g_tests[key].result); - } + if (ret) + printf("TEST FAILED. ret code : %d\n", g_tests[key].result); else - { - printf( "TEST SUCCEDED. ret code : %d\n", g_tests[key].result); - } + printf("TEST SUCCEDED. ret code : %d\n", g_tests[key].result); } - /* test items...*/ int __test_radio_init(void) { @@ -206,8 +184,8 @@ int __test_radio_init(void) int ret = RADIO_ERROR_NONE; radio_h radio; - RADIO_TEST__( radio_create(&radio); ) - RADIO_TEST__( radio_destroy(radio); ) + RADIO_TEST__(radio_create(&radio);) + RADIO_TEST__(radio_destroy(radio);) return ret; } @@ -218,12 +196,12 @@ int __test_radio_listen_gorealra(void) int ret = RADIO_ERROR_NONE; radio_h radio; - RADIO_TEST__( radio_create(&radio); ) - RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); ) - RADIO_TEST__( radio_start(radio); ) + RADIO_TEST__(radio_create(&radio);) + RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);) + RADIO_TEST__(radio_start(radio);) usleep(5000 * 1000); - RADIO_TEST__( radio_stop(radio); ) - RADIO_TEST__( radio_destroy(radio); ) + RADIO_TEST__(radio_stop(radio);) + RADIO_TEST__(radio_destroy(radio);) return ret; } @@ -235,11 +213,9 @@ int __test_repeat_init_release(void) int cnt = 0; radio_h radio; - while ( cnt < 1000 ) - { - RADIO_TEST__( radio_create(&radio); ) - RADIO_TEST__( radio_destroy(radio); ) - + while (cnt < 1000) { + RADIO_TEST__(radio_create(&radio);) + RADIO_TEST__(radio_destroy(radio);) cnt++; printf("%s : repeat count : %d\n", __FUNCTION__, cnt); @@ -255,17 +231,14 @@ int __test_repeat_start_stop(void) int cnt = 0; radio_h radio; - RADIO_TEST__( radio_create(&radio); ) - RADIO_TEST__( radio_set_frequency( radio, DEFAULT_TEST_FREQ ); ) + RADIO_TEST__(radio_create(&radio);) + RADIO_TEST__(radio_set_frequency(radio, DEFAULT_TEST_FREQ);) - while(cnt < 10) - { - RADIO_TEST__( radio_start(radio); ) + while (cnt < 10) { + RADIO_TEST__(radio_start(radio);) usleep(2000 * 1000); - RADIO_TEST__( radio_stop(radio); ) - + RADIO_TEST__(radio_stop(radio);) cnt++; - printf("%s : repeat count : %d\n", __FUNCTION__, cnt); } @@ -292,22 +265,20 @@ int __test_manual_api_calling(void) return 0; } - int radio_rt_api_test(void) { - while(1) - { + while (1) { int choosen = 0; choosen = __menu(); - if ( choosen == -1) + if (choosen == -1) continue; - if ( choosen == 0 ) + if (choosen == 0) break; - __call_api( choosen ); + __call_api(choosen); } printf("radio test client finished\n"); @@ -347,189 +318,182 @@ int __menu(void) printf("---------------------------------------------------------\n"); printf("choose one : "); - if ( scanf("%d", &menu_item) == 0) - { + if (scanf("%d", &menu_item) == 0) { char temp[_MAX_INPUT_STRING_]; - if (scanf("%s", temp) ==0) - { + if (scanf("%s", temp) == 0) printf("Error while flushing the input buffer - but lets continue\n"); - } return -1; } - - if ( menu_item > MENU_ITEM_MAX ) + if (menu_item > MENU_ITEM_MAX) menu_item = -1; return menu_item; } -void __call_api( int choosen ) +void __call_api(int choosen) { int ret = RADIO_ERROR_NONE; - switch( choosen ) - { - case 1: + switch (choosen) { + case 1: { - RADIO_TEST__( radio_create( &g_my_radio ); ) + RADIO_TEST__(radio_create(&g_my_radio);) } break; - case 2: + case 2: { - RADIO_TEST__( radio_destroy( g_my_radio ); ) + RADIO_TEST__(radio_destroy(g_my_radio);) g_my_radio = 0; } break; - case 3: + case 3: { radio_state_e state; - RADIO_TEST__( radio_get_state(g_my_radio, &state); ) - + RADIO_TEST__(radio_get_state(g_my_radio, &state);) printf("state : %d\n", state); } break; - case 4: + case 4: { - RADIO_TEST__( radio_start(g_my_radio); ) + RADIO_TEST__(radio_start(g_my_radio);) } break; - case 5: + case 5: { - RADIO_TEST__( radio_stop(g_my_radio); ) + RADIO_TEST__(radio_stop(g_my_radio);) } break; - case 6: + case 6: { - RADIO_TEST__( radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL); ) + RADIO_TEST__(radio_seek_up(g_my_radio, __radio_seek_completed_cb, NULL);) } break; - case 7: + case 7: { - RADIO_TEST__( radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL); ) + RADIO_TEST__(radio_seek_down(g_my_radio, __radio_seek_completed_cb, NULL);) } break; - case 8: + case 8: { int freq = 0; printf("input freq : "); if (scanf("%d", &freq) == 0) return; - RADIO_TEST__( radio_set_frequency(g_my_radio, freq); ) + RADIO_TEST__(radio_set_frequency(g_my_radio, freq);) } break; - case 9: + case 9: { int freq = 0; - RADIO_TEST__( radio_get_frequency(g_my_radio, &freq ); ) + RADIO_TEST__(radio_get_frequency(g_my_radio, &freq);) - printf("freq : %d\n", freq); + printf("freq : %d\n", freq); } break; - case 10: + case 10: { int signal_strength = 0; - RADIO_TEST__( radio_get_signal_strength(g_my_radio, &signal_strength); ) + RADIO_TEST__(radio_get_signal_strength(g_my_radio, &signal_strength);) printf("signal strength is : %d \n", signal_strength); } break; - case 11: + case 11: { - RADIO_TEST__( radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL); ) + RADIO_TEST__(radio_scan_start(g_my_radio, &__radio_scan_updated_cb, NULL);) } break; - case 12: + case 12: { - RADIO_TEST__( radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL); ) + RADIO_TEST__(radio_scan_stop(g_my_radio, &__radio_scan_stop_cb, NULL);) } break; - case 13: + case 13: { int muted = 0; printf("select one(0:UNMUTE/1:MUTE) : "); - if ( scanf("%d", &muted) == 0) + if (scanf("%d", &muted) == 0) return; - RADIO_TEST__( radio_set_mute(g_my_radio, muted); ) + RADIO_TEST__(radio_set_mute(g_my_radio, muted);) } break; - case 14: + case 14: { bool muted = 0; - RADIO_TEST__( radio_is_muted(g_my_radio, &muted); ) + RADIO_TEST__(radio_is_muted(g_my_radio, &muted);) printf("muted : %d \n", muted); } break; - - case 15: + case 15: { - RADIO_TEST__( radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL); ) + RADIO_TEST__(radio_set_scan_completed_cb(g_my_radio, &__radio_set_scan_completed_cb, NULL);) } break; - case 16: + case 16: { - RADIO_TEST__( radio_unset_scan_completed_cb(g_my_radio); ) + RADIO_TEST__(radio_unset_scan_completed_cb(g_my_radio);) } break; - case 17: + case 17: { - RADIO_TEST__( radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL ); ) + RADIO_TEST__(radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL);) } break; - case 18: + case 18: { - RADIO_TEST__( radio_unset_interrupted_cb(g_my_radio); ) + RADIO_TEST__(radio_unset_interrupted_cb(g_my_radio);) } break; - case 19: + case 19: { int min = 0; int max = 0; - RADIO_TEST__( radio_get_frequency_range(g_my_radio, &min, &max); ) + RADIO_TEST__(radio_get_frequency_range(g_my_radio, &min, &max);) printf("min : %d max: %d \n", min, max); } break; - case 20: + case 20: { int channel_spacing = 0; - RADIO_TEST__( radio_get_channel_spacing(g_my_radio, &channel_spacing); ) + RADIO_TEST__(radio_get_channel_spacing(g_my_radio, &channel_spacing);) printf("channel_spacing : %d \n", channel_spacing); } break; - default: - break; + default: + break; } } - void __radio_seek_completed_cb(int frequency, void *user_data) { - printf("__radio_seek_completed_cb freq is %d\n" , frequency); + printf("__radio_seek_completed_cb freq is %d\n", frequency); } + void __radio_scan_updated_cb(int frequency, void *user_param) { - printf("__radio_scan_updated_cb freq is %d\n" , frequency); + printf("__radio_scan_updated_cb freq is %d\n", frequency); } void __radio_scan_stop_cb(void *user_param) @@ -546,4 +510,3 @@ void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param) { printf("__radio_set_interrupted_cb\n"); } - diff --git a/test/radio_test_type.h b/test/radio_test_type.h index 5363cdd..7b23e30 100755 --- a/test/radio_test_type.h +++ b/test/radio_test_type.h @@ -27,8 +27,7 @@ typedef int (*test_function) (void); -typedef struct __test_item -{ +typedef struct __test_item { char menu_string[80]; char description[128]; test_function func; @@ -36,14 +35,12 @@ typedef struct __test_item } test_item_t; #define RADIO_TEST__(x_test) \ + do { \ ret = x_test \ - if ( ! ret ) \ - { \ + if (!ret) \ printf("PASS : %s -- %s:%d\n", #x_test, __FILE__, __LINE__); \ - } \ else \ - { \ printf("FAIL : %s ERR-CODE : 0x%x -- %s:%d\n", #x_test, ret, __FILE__, __LINE__); \ - } + } while (0) -#endif /* MM_RADIO_TEST_TYPE_H_ */ +#endif /* MM_RADIO_TEST_TYPE_H_ */