From: Gilbok Lee Date: Mon, 16 Jul 2018 07:50:36 +0000 (+0900) Subject: Modified radio hal interface X-Git-Tag: submit/tizen/20180720.020744^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4e48794c3077d6b0838762edabf94b4a29c7e3d;p=platform%2Fcore%2Fmultimedia%2Flibmm-radio.git Modified radio hal interface [Version] 0.2.41 [Profile] Mobile, Wearable [Issue Type] Refactoring Change-Id: I90d5692093c7d85165a72f206b6a7546ecd6c98f --- diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec index b94b983..9657dc6 100755 --- a/packaging/libmm-radio.spec +++ b/packaging/libmm-radio.spec @@ -1,6 +1,6 @@ Name: libmm-radio Summary: Multimedia Framework Radio Library -Version: 0.2.40 +Version: 0.2.41 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/src/include/mm_radio_priv_hal.h b/src/include/mm_radio_priv_hal.h index 31fb1ce..3270314 100644 --- a/src/include/mm_radio_priv_hal.h +++ b/src/include/mm_radio_priv_hal.h @@ -215,7 +215,7 @@ typedef struct { /* region settings */ MMRadioRegion_t region_setting; - mm_radio_hal_interface *hal_inf; + radio_hal_interface *hal_inf; mm_resource_manager_h resource_manager; mm_resource_manager_res_h radio_resource; diff --git a/src/include/radio_hal_interface.h b/src/include/radio_hal_interface.h index 058b52f..cb4a1d0 100644 --- a/src/include/radio_hal_interface.h +++ b/src/include/radio_hal_interface.h @@ -31,29 +31,29 @@ typedef enum _seek_direction_type { SEEK_DIRECTION_DOWN /**< Seek downward */ } seek_direction_type_t; -typedef struct _mmradio_hal_interface { +typedef struct _radio_hal_interface { void *dl_handle; void *rh_handle; radio_interface_t intf; -} mm_radio_hal_interface; +} radio_hal_interface; -int radio_hal_interface_init(mm_radio_hal_interface **handle); -int radio_hal_interface_deinit(mm_radio_hal_interface *handle); -int radio_hal_open(mm_radio_hal_interface *radio_handle); -int radio_hal_prepare(mm_radio_hal_interface *radio_handle); -int radio_hal_unprepare(mm_radio_hal_interface *radio_handle); -int radio_hal_close(mm_radio_hal_interface *radio_handle); -int radio_hal_start(mm_radio_hal_interface *radio_handle); -int radio_hal_stop(mm_radio_hal_interface *radio_handle); -int radio_hal_seek(mm_radio_hal_interface *radio_handle, seek_direction_type_t direction); -int radio_hal_get_frequency(mm_radio_hal_interface *radio_handle, uint32_t *frequency); -int radio_hal_set_frequency(mm_radio_hal_interface *radio_handle, uint32_t frequency); -int radio_hal_get_signal_strength(mm_radio_hal_interface *radio_handle, int32_t *strength); -int radio_hal_mute(mm_radio_hal_interface *radio_handle); -int radio_hal_unmute(mm_radio_hal_interface *radio_handle); -int radio_hal_set_volume(mm_radio_hal_interface *radio_handle, float volume); -int radio_hal_get_volume(mm_radio_hal_interface *radio_handle, float *volume); -int radio_hal_set_media_volume(mm_radio_hal_interface *radio_handle, uint32_t level); +int radio_hal_interface_init(radio_hal_interface **handle); +int radio_hal_interface_deinit(radio_hal_interface *handle); +int radio_hal_open(radio_hal_interface *handle); +int radio_hal_prepare(radio_hal_interface *handle); +int radio_hal_unprepare(radio_hal_interface *handle); +int radio_hal_close(radio_hal_interface *handle); +int radio_hal_start(radio_hal_interface *handle); +int radio_hal_stop(radio_hal_interface *handle); +int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction); +int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency); +int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency); +int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength); +int radio_hal_mute(radio_hal_interface *handle); +int radio_hal_unmute(radio_hal_interface *handle); +int radio_hal_set_volume(radio_hal_interface *handle, float volume); +int radio_hal_get_volume(radio_hal_interface *handle, float *volume); +int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level); #ifdef __cplusplus diff --git a/src/include/tizen-radio.h b/src/include/tizen-radio.h index 4f1493a..494df04 100644 --- a/src/include/tizen-radio.h +++ b/src/include/tizen-radio.h @@ -44,7 +44,6 @@ extern "C" { typedef enum radio_error { RADIO_ERROR_NONE, RADIO_ERROR_INVALID_PARAMETER, - RADIO_ERROR_INVALID_STATE, RADIO_ERROR_INVALID_OPERATION, RADIO_ERROR_PERMISSION_DENIED, RADIO_ERROR_NOT_SUPPORTED, @@ -52,9 +51,9 @@ typedef enum radio_error { RADIO_ERROR_DEVICE_NOT_PREPARED, RADIO_ERROR_DEVICE_NOT_OPENED, RADIO_ERROR_DEVICE_NOT_FOUND, - RADIO_ERROR_DEVICE_NOT_SUPPORTED, RADIO_ERROR_NO_ANTENNA, RADIO_ERROR_INTERNAL, + RADIO_ERROR_NOT_IMPLEMENTED, RADIO_ERROR_UNKNOWN } radio_error_t; @@ -96,6 +95,7 @@ typedef struct radio_interface { * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RADIO_ERROR_OUT_OF_MEMORY Out of memory + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_deinit() */ radio_error_t radio_init(void **radio_handle); @@ -118,7 +118,7 @@ radio_error_t radio_deinit(void *radio_handle); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_unprepare() */ radio_error_t radio_prepare(void *radio_handle); @@ -130,6 +130,7 @@ radio_error_t radio_prepare(void *radio_handle); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_prepare() */ radio_error_t radio_unprepare(void *radio_handle); @@ -142,7 +143,7 @@ radio_error_t radio_unprepare(void *radio_handle); * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter * @retval #RADIO_ERROR_DEVICE_NOT_FOUND Failed to find radio device - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @retval #RADIO_ERROR_PERMISSION_DENIED The access to the resources can not be granted. * @retval #RADIO_ERROR_DEVICE_NOT_PREPARED Not prepared the radio device * @see radio_close() @@ -156,6 +157,8 @@ radio_error_t radio_open(void *radio_handle); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. + * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation * @see radio_open() */ radio_error_t radio_close(void *radio_handle); @@ -167,6 +170,7 @@ radio_error_t radio_close(void *radio_handle); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. * @see radio_stop() */ radio_error_t radio_start(void *radio_handle); @@ -178,6 +182,7 @@ radio_error_t radio_start(void *radio_handle); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened. * @see radio_start() */ radio_error_t radio_stop(void *radio_handle); @@ -203,7 +208,6 @@ radio_error_t radio_seek(void *radio_handle, radio_seek_direction_type_t directi * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation */ radio_error_t radio_get_frequency(void *radio_handle, uint32_t *frequency); @@ -216,7 +220,6 @@ radio_error_t radio_get_frequency(void *radio_handle, uint32_t *frequency); * @return @c 0 on success, otherwise a negative error value * @retval #RADIO_ERROR_NONE Successful * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation */ radio_error_t radio_set_frequency(void *radio_handle, uint32_t frequency); diff --git a/src/mm_radio_priv_emulator.c b/src/mm_radio_priv_emulator.c index ff3a9a6..1e8c418 100644 --- a/src/mm_radio_priv_emulator.c +++ b/src/mm_radio_priv_emulator.c @@ -1595,6 +1595,9 @@ static void __mmradio_destroy_thread_type(mm_radio_t *radio, MMRadioThreadTypes pthread_join(p_thread->thread, NULL); p_thread->thread = 0; break; + default: + MMRADIO_LOG_WARNING("(%d)type isn't handled", type); + break; } } else { MMRADIO_LOG_WARNING("(%d)thread is zero", type); diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c index f875a77..24604b5 100644 --- a/src/mm_radio_priv_hal.c +++ b/src/mm_radio_priv_hal.c @@ -142,6 +142,60 @@ thread_function __mmradio_thread_function[] = { &__mmradio_scan_thread }; +static int __convert_error_code(int code, char *func_name) +{ + int ret = MM_ERROR_NONE; + char *msg = "MM_ERROR_NONE"; + MMRADIO_LOG_DEBUG("[%s] Enter code :%x", func_name, code); + + switch (code) { + + case RADIO_ERROR_NONE: + ret = MM_ERROR_NONE; + msg = "MM_ERROR_NONE"; + break; + case RADIO_ERROR_INVALID_PARAMETER: + ret = MM_ERROR_INVALID_ARGUMENT; + msg = "MM_ERROR_INVALID_ARGUMENT"; + break; + case RADIO_ERROR_PERMISSION_DENIED: + ret = MM_ERROR_RADIO_PERMISSION_DENIED; + msg = "MM_ERROR_RADIO_PERMISSION_DENIED"; + break; + case RADIO_ERROR_NOT_SUPPORTED: + case RADIO_ERROR_NOT_IMPLEMENTED: + ret = MM_ERROR_NOT_IMPLEMENTED; + msg = "MM_ERROR_NOT_IMPLEMENTED"; + break; + case RADIO_ERROR_OUT_OF_MEMORY: + ret = MM_ERROR_OUT_OF_MEMORY; + msg = "MM_ERROR_OUT_OF_MEMORY"; + break; + case RADIO_ERROR_DEVICE_NOT_PREPARED: + case RADIO_ERROR_DEVICE_NOT_OPENED: + ret = MM_ERROR_RADIO_DEVICE_NOT_OPENED; + msg = "MM_ERROR_RADIO_DEVICE_NOT_OPENED"; + break; + case RADIO_ERROR_DEVICE_NOT_FOUND: + ret = MM_ERROR_RADIO_DEVICE_NOT_FOUND; + msg = "MM_ERROR_RADIO_DEVICE_NOT_FOUND"; + break; + case RADIO_ERROR_NO_ANTENNA: + ret = MM_ERROR_RADIO_NO_ANTENNA; + msg = "MM_ERROR_RADIO_NO_ANTENNA"; + break; + case RADIO_ERROR_INVALID_OPERATION: + case RADIO_ERROR_UNKNOWN: + case RADIO_ERROR_INTERNAL: + default: + ret = MM_ERROR_RADIO_INTERNAL; + msg = "MM_ERROR_RADIO_INTERNAL"; + break; + } + MMRADIO_LOG_ERROR("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code); + return ret; +} + int _mmradio_apply_region(mm_radio_t *radio, MMRadioRegionType region, bool update) { int ret = MM_ERROR_NONE; @@ -227,6 +281,7 @@ int _mmradio_create_radio(mm_radio_t *radio) ret = radio_hal_interface_init(&(radio->hal_inf)); if (ret) { MMRADIO_LOG_ERROR("failed to init mmradio hal interface"); + ret = __convert_error_code(ret, (char *)__FUNCTION__); goto ERROR_HAL_INIT; } @@ -367,7 +422,7 @@ int _mmradio_destroy(mm_radio_t *radio) ret = radio_hal_interface_deinit(radio->hal_inf); if (ret) { MMRADIO_LOG_ERROR("failed to deinitialize radio hal interface"); - return ret; + return __convert_error_code(ret, (char *)__FUNCTION__); } ret = mm_resource_manager_destroy(radio->resource_manager); @@ -396,15 +451,14 @@ int _mmradio_set_frequency(mm_radio_t *radio, int freq) radio->freq = freq; ret = radio_hal_set_frequency(radio->hal_inf, freq); - if (ret != MM_ERROR_NONE) { + if (ret) { MMRADIO_LOG_ERROR("failed to set radio hal frequency"); - MMRADIO_LOG_FLEAVE(); - return ret; + return __convert_error_code(ret, (char *)__FUNCTION__); } MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } @@ -420,10 +474,10 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq) MMRADIO_RETURN_VAL_IF_FAIL(pFreq, MM_ERROR_INVALID_ARGUMENT); ret = radio_hal_get_frequency(radio->hal_inf, &freq); - if (ret != MM_ERROR_NONE) { + if (ret) { MMRADIO_LOG_ERROR("failed to get radio hal frequency"); *pFreq = 0; - return ret; + return __convert_error_code(ret, (char *)__FUNCTION__); } /* update freq in handle */ @@ -434,7 +488,7 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq) MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } int _mmradio_mute(mm_radio_t *radio) @@ -446,11 +500,12 @@ int _mmradio_mute(mm_radio_t *radio) MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_MUTE); ret = radio_hal_mute(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to set radio hal mute"); - MMRADIO_LOG_FLEAVE(); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) + MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); + else + MMRADIO_LOG_ERROR("failed to set radio hal mute"); return ret; } @@ -458,7 +513,7 @@ int _mmradio_mute(mm_radio_t *radio) MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted); MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } int _mmradio_unmute(mm_radio_t *radio) @@ -470,11 +525,12 @@ int _mmradio_unmute(mm_radio_t *radio) MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_UNMUTE); ret = radio_hal_unmute(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to set radio hal unmute"); - MMRADIO_LOG_FLEAVE(); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) + MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); + else + MMRADIO_LOG_ERROR("failed to set radio hal unmute"); return ret; } @@ -482,7 +538,7 @@ int _mmradio_unmute(mm_radio_t *radio) MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted); MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } int _mmradio_set_message_callback(mm_radio_t *radio, MMMessageCallback callback, void *user_param) @@ -551,19 +607,25 @@ int _mmradio_start(mm_radio_t *radio) } ret = radio_hal_prepare(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_prepare is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to prepare radio hal"); - goto error2; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_prepare is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to prepare radio hal"); + goto error2; + } } ret = radio_hal_open(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_open is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to open radio hal"); - goto error1; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_open is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to open radio hal"); + goto error1; + } } radio->is_ready = true; } else { @@ -581,17 +643,21 @@ int _mmradio_start(mm_radio_t *radio) } ret = radio_hal_start(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_start is not supported"); - } else if (ret) { - MMRADIO_LOG_ERROR("failed to start radio hal"); - goto error1; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_start is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to start radio hal"); + goto error1; + } } /* set stored frequency */ ret = radio_hal_set_frequency(radio->hal_inf, radio->freq); if (ret) { MMRADIO_LOG_ERROR("failed to set radio hal frequency"); + ret = __convert_error_code(ret, (char *)__FUNCTION__); goto error1; } @@ -637,29 +703,38 @@ int _mmradio_stop(mm_radio_t *radio) #endif ret = radio_hal_stop(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); - } else if (ret) { - MMRADIO_LOG_ERROR("failed to stop radio hal"); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to stop radio hal"); + return ret; + } } if (radio->is_ready) { /* close radio device here !!!! */ ret = radio_hal_close(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_close is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to close radio hal"); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_SUPPORT_API) { + MMRADIO_LOG_WARNING("radio_hal_close is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to close radio hal"); + return ret; + } } ret = radio_hal_unprepare(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to unprepare radio hal"); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_SUPPORT_API) { + MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to unprepare radio hal"); + return ret; + } } if (!radio->interrupted_by_resource_conflict && /* is being released */ @@ -709,11 +784,14 @@ int _mmradio_seek(mm_radio_t *radio, MMRadioSeekDirectionType direction) if (!radio->is_muted) { ret = radio_hal_mute(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); - } else if (ret) { - MMRADIO_LOG_ERROR("failed to set radio hal mute"); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to set radio hal mute"); + return ret; + } } radio->seek_unmute = true; } @@ -777,21 +855,27 @@ int _mmradio_start_scan(mm_radio_t *radio) } ret = radio_hal_prepare(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_prepare is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to prepare radio hal"); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_prepare is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to prepare radio hal"); + return ret; + } } ret = radio_hal_open(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_open is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to open radio hal"); - MMRADIO_LOG_FLEAVE(); - return ret; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_open is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to open radio hal"); + return ret; + } } + radio->is_ready = true; } else { MMRADIO_LOG_DEBUG("radio prepared and opened"); @@ -833,12 +917,13 @@ int _mm_radio_get_signal_strength(mm_radio_t *radio, int *value) /* just return stored frequency if radio device is not ready */ ret = radio_hal_get_signal_strength(radio->hal_inf, &strength); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to get radio hal signal strength"); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) + MMRADIO_LOG_WARNING("radio_hal_get_signal_strength is not supported"); + else + MMRADIO_LOG_ERROR("failed to get radio hal signal strength"); *value = 0; - MMRADIO_LOG_FLEAVE(); return ret; } *value = (int)strength; @@ -876,16 +961,19 @@ void __mmradio_scan_thread(mm_radio_t *radio) if (radio->old_state == MM_RADIO_STATE_PLAYING) { ret = radio_hal_mute(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("faied to set radio hal mute"); - goto FINISHED; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_mute is not supported"); + } else { + MMRADIO_LOG_ERROR("faied to set radio hal mute"); + goto FINISHED; + } } } ret = radio_hal_set_frequency(radio->hal_inf, radio->region_setting.band_min); - if (ret != MM_ERROR_NONE) + if (ret) goto FINISHED; MMRADIO_POST_MSG(radio, MM_MESSAGE_RADIO_SCAN_START, NULL); @@ -910,7 +998,7 @@ void __mmradio_scan_thread(mm_radio_t *radio) MMRADIO_HAL_SEEK_THREAD_LOCK(radio); ret = radio_hal_seek(radio->hal_inf, MM_RADIO_SEEK_UP); MMRADIO_HAL_SEEK_THREAD_UNLOCK(radio); - if (ret != MM_ERROR_NONE) { + if (ret) { MMRADIO_LOG_ERROR("radio scanning error"); break; } @@ -927,7 +1015,7 @@ void __mmradio_scan_thread(mm_radio_t *radio) /* now we can get new frequency from radio device */ ret = radio_hal_get_frequency(radio->hal_inf, &freq); - if (ret != MM_ERROR_NONE) { + if (ret) { MMRADIO_LOG_ERROR("failed to get current frequency"); } else { if (freq <= prev_freq) { @@ -959,16 +1047,17 @@ FINISHED: } else if (radio->old_state == MM_RADIO_STATE_PLAYING) { MMRADIO_LOG_DEBUG("old state is playing"); ret = radio_hal_unmute(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); - } else if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to set radio hal unmute"); - goto FINISHED_ERR; + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to set radio hal unmute"); + goto FINISHED_ERR; + } } ret = radio_hal_set_frequency(radio->hal_inf, prev_freq); - if (ret == MM_ERROR_NOT_SUPPORT_API) { - MMRADIO_LOG_WARNING("radio_hal_set_frequency is not supported"); - } else if (ret != MM_ERROR_NONE) { + if (ret) { MMRADIO_LOG_ERROR("failed to set radio hal frequency"); goto FINISHED_ERR; } @@ -981,16 +1070,12 @@ FINISHED_ERR: /* close radio device here !!!! */ if (radio->is_ready) { ret = radio_hal_close(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) - MMRADIO_LOG_WARNING("radio_hal_close is not supported"); - else if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to close radio hal"); + if (ret) + __convert_error_code(ret, (char *)__FUNCTION__); ret = radio_hal_unprepare(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) - MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported"); - else if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to unprepare radio hal"); + if (ret) + __convert_error_code(ret, (char *)__FUNCTION__); if (!radio->interrupted_by_resource_conflict && /* is being released */ radio->radio_resource != NULL) { @@ -1136,8 +1221,13 @@ void __mmradio_seek_thread(mm_radio_t *radio) */ ret = radio_hal_unmute(radio->hal_inf); if (ret) { - MMRADIO_LOG_ERROR("failed to set unmute radio hal"); - goto SEEK_FAILED; + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_unmute is not supported"); + } else { + MMRADIO_LOG_ERROR("failed to set radio hal unmute"); + goto SEEK_FAILED; + } } radio->seek_unmute = false; } @@ -1446,12 +1536,18 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume) MMRADIO_VOLUME_UNLOCK(radio); ret = radio_hal_set_volume(radio->hal_inf, volume); - if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to set radio hal volume"); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) + MMRADIO_LOG_WARNING("radio_hal_set_volume is not supported"); + else + MMRADIO_LOG_ERROR("failed to set radio hal volume"); + return ret; + } MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } int _mmradio_get_volume(mm_radio_t *radio, float *pVolume) @@ -1466,8 +1562,12 @@ int _mmradio_get_volume(mm_radio_t *radio, float *pVolume) MMRADIO_RETURN_VAL_IF_FAIL(pVolume, MM_ERROR_INVALID_ARGUMENT); ret = radio_hal_get_volume(radio->hal_inf, &volume); - if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to get radio hal volume"); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) + MMRADIO_LOG_WARNING("radio_hal_get_volume is not supported"); + else + MMRADIO_LOG_ERROR("failed to get radio hal volume"); *pVolume = 0; return ret; } @@ -1498,12 +1598,19 @@ static int __mmradio_set_media_volume(mm_radio_t *radio, unsigned int level) MMRADIO_VOLUME_UNLOCK(radio); ret = radio_hal_set_media_volume(radio->hal_inf, level); - if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to set radio hal media volume"); + if (ret) { + ret = __convert_error_code(ret, (char *)__FUNCTION__); + if (ret == MM_ERROR_NOT_IMPLEMENTED) { + MMRADIO_LOG_WARNING("radio_hal_set_media_volume is not supported"); + } else if (ret != MM_ERROR_NONE) { + MMRADIO_LOG_ERROR("failed to set radio hal media volume"); + return ret; + } + } MMRADIO_LOG_FLEAVE(); - return ret; + return MM_ERROR_NONE; } static int __resource_release_cb(mm_resource_manager_h rm, @@ -1650,6 +1757,8 @@ static void __mmradio_destroy_thread_type(mm_radio_t *radio, MMRadioThreadTypes pthread_join(p_thread->thread, NULL); p_thread->thread = 0; break; + default: + MMRADIO_LOG_WARNING("(%d)type isn't handled", type); } } else { MMRADIO_LOG_WARNING("(%d)thread is zero", type); diff --git a/src/radio_hal_interface.c b/src/radio_hal_interface.c index 567c469..b4f683b 100644 --- a/src/radio_hal_interface.c +++ b/src/radio_hal_interface.c @@ -22,74 +22,35 @@ extern "C" { #endif /* __cplusplus */ #include -#include "mm_radio_utils.h" +#include + #include "radio_hal_interface.h" +#ifdef LOG_TAG +#undef LOG_TAG +#endif /* LOG_TAG */ + +#define LOG_TAG "RADIO_HAL_INTF" + #define LIB_TIZEN_RADIO PATH_LIBDIR"/libtizen-radio.so" -static int __convert_error_code(int code, char *func_name) -{ - int ret = RADIO_ERROR_NONE; - char *msg = "RADIO_ERROR_NONE"; - MMRADIO_LOG_DEBUG("[%s] Enter code :%x", func_name, code); - - switch (code) { - - case RADIO_ERROR_NONE: - ret = MM_ERROR_NONE; - msg = "MM_ERROR_NONE"; - break; - case RADIO_ERROR_INVALID_PARAMETER: - ret = MM_ERROR_COMMON_INVALID_ARGUMENT; - msg = "MM_ERROR_COMMON_INVALID_ARGUMENT"; - break; - case RADIO_ERROR_INVALID_STATE: - ret = MM_ERROR_RADIO_INVALID_STATE; - msg = "MM_ERROR_RADIO_INVALID_STATE"; - break; - case RADIO_ERROR_OUT_OF_MEMORY: - ret = MM_ERROR_RADIO_NO_FREE_SPACE; - msg = "MM_ERROR_RADIO_NO_FREE_SPACE"; - break; - case RADIO_ERROR_PERMISSION_DENIED: - case RADIO_ERROR_DEVICE_NOT_PREPARED: - ret = MM_ERROR_RADIO_PERMISSION_DENIED; - msg = "MM_ERROR_RADIO_PERMISSION_DENIED"; - break; - case RADIO_ERROR_DEVICE_NOT_OPENED: - ret = MM_ERROR_RADIO_DEVICE_NOT_OPENED; - msg = "MM_ERROR_RADIO_DEVICE_NOT_OPENED"; - break; - case RADIO_ERROR_NOT_SUPPORTED: - case RADIO_ERROR_DEVICE_NOT_SUPPORTED: - case RADIO_ERROR_DEVICE_NOT_FOUND: - ret = MM_ERROR_RADIO_DEVICE_NOT_FOUND; - msg = "MM_ERROR_RADIO_DEVICE_NOT_FOUND"; - break; - case RADIO_ERROR_NO_ANTENNA: - ret = MM_ERROR_RADIO_NO_ANTENNA; - msg = "MM_ERROR_RADIO_NO_ANTENNA"; - break; - case RADIO_ERROR_UNKNOWN: - case RADIO_ERROR_INTERNAL: - default: - ret = MM_ERROR_RADIO_INTERNAL; - msg = "MM_ERROR_RADIO_INTERNAL"; - break; - } - MMRADIO_LOG_ERROR("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code); - return ret; -} +#define RADIO_INTF_CHECK_ARG(x_radio) \ +do { \ + if (!x_radio) { \ + LOGE("argument is NULL\n"); \ + return RADIO_ERROR_INVALID_PARAMETER; \ + } \ +} while (0) -int radio_hal_interface_init(mm_radio_hal_interface **handle) +int radio_hal_interface_init(radio_hal_interface **handle) { - mm_radio_hal_interface *h = NULL; - int ret = MM_ERROR_NONE; - h = (mm_radio_hal_interface *)malloc(sizeof(mm_radio_hal_interface)); + radio_hal_interface *h = NULL; + int ret = RADIO_ERROR_NONE; + h = (radio_hal_interface *)malloc(sizeof(radio_hal_interface)); if (!h) { - MMRADIO_LOG_ERROR("cannot allocate memory for radio_hal interface"); - return MM_ERROR_RADIO_NO_FREE_SPACE; + LOGE("cannot allocate memory for radio_hal interface"); + return RADIO_ERROR_OUT_OF_MEMORY; } h->dl_handle = dlopen(LIB_TIZEN_RADIO, RTLD_NOW); @@ -114,28 +75,27 @@ int radio_hal_interface_init(mm_radio_hal_interface **handle) h->intf.set_media_volume = dlsym(h->dl_handle, "radio_set_media_volume"); if (h->intf.init == NULL || h->intf.deinit == NULL) { - MMRADIO_LOG_ERROR("could not get mandatory funtion"); + LOGE("could not get mandatory funtion"); goto FAIL; } - if (h->intf.init) { - ret = h->intf.init(&h->rh_handle); - if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("radio_hal init failed %d", ret); - goto FAIL; - } + ret = h->intf.init(&h->rh_handle); + if (ret != RADIO_ERROR_NONE) { + LOGE("radio_hal init failed %d", ret); + goto FAIL; } + } else { - MMRADIO_LOG_ERROR("open radio hal_interface failed : %s", dlerror()); - ret = MM_ERROR_RADIO_INTERNAL; + LOGE("open radio hal_interface failed : %s", dlerror()); + ret = RADIO_ERROR_INTERNAL; goto FAIL; } *handle = h; - MMRADIO_LOG_DEBUG("open radio_hal interface"); + LOGD("open radio_hal interface"); - return MM_ERROR_NONE; + return ret; FAIL: if (h) { if (h->dl_handle) @@ -146,19 +106,19 @@ FAIL: return ret; } -int radio_hal_interface_deinit(mm_radio_hal_interface *handle) +int radio_hal_interface_deinit(radio_hal_interface *handle) { - int ret = MM_ERROR_NONE; - MMRADIO_CHECK_ARG(handle); + int ret = RADIO_ERROR_NONE; + RADIO_INTF_CHECK_ARG(handle); if (handle->dl_handle) { ret = handle->intf.deinit(handle->rh_handle); if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); + return ret; handle->rh_handle = NULL; - MMRADIO_LOG_DEBUG("close radio_hal interface"); + LOGD("close radio_hal interface"); dlclose(handle->dl_handle); handle->dl_handle = NULL; } @@ -169,234 +129,186 @@ int radio_hal_interface_deinit(mm_radio_hal_interface *handle) return ret; } -int radio_hal_open(mm_radio_hal_interface *radio_handle) +int radio_hal_open(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.open) { - ret = radio_handle->intf.open(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal open is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.open) { + LOGW("radio_hal open is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.open(handle->rh_handle); } -int radio_hal_prepare(mm_radio_hal_interface *radio_handle) +int radio_hal_prepare(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.prepare) { - ret = radio_handle->intf.prepare(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal prepare is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.prepare) { + LOGW("radio_hal prepare is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.prepare(handle->rh_handle); } -int radio_hal_unprepare(mm_radio_hal_interface *radio_handle) +int radio_hal_unprepare(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.prepare) { - ret = radio_handle->intf.unprepare(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal prepare is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.unprepare) { + LOGW("radio_hal unprepare is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.unprepare(handle->rh_handle); } -int radio_hal_close(mm_radio_hal_interface *radio_handle) +int radio_hal_close(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.close) { - ret = radio_handle->intf.close(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal close is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.close) { + LOGW("radio_hal close is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.close(handle->rh_handle); } -int radio_hal_start(mm_radio_hal_interface *radio_handle) +int radio_hal_start(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.start) { - ret = radio_handle->intf.start(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal start is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.start) { + LOGW("radio_hal start is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.start(handle->rh_handle); } -int radio_hal_stop(mm_radio_hal_interface *radio_handle) +int radio_hal_stop(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.stop) { - ret = radio_handle->intf.stop(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal stop is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.stop) { + LOGW("radio_hal stop is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.stop(handle->rh_handle); } -int radio_hal_seek(mm_radio_hal_interface *radio_handle, seek_direction_type_t direction) +int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.seek) { - ret = radio_handle->intf.seek(radio_handle->rh_handle, (radio_seek_direction_type_t)direction); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal seek is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.seek) { + LOGW("radio_hal seek is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.seek(handle->rh_handle, (radio_seek_direction_type_t)direction); } -int radio_hal_get_frequency(mm_radio_hal_interface *radio_handle, uint32_t *frequency) +int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.get_frequency) { - ret = radio_handle->intf.get_frequency(radio_handle->rh_handle, frequency); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal get_frequency is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_frequency) { + LOGW("radio_hal get_frequency is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.get_frequency(handle->rh_handle, frequency); } -int radio_hal_set_frequency(mm_radio_hal_interface *radio_handle, uint32_t frequency) +int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.set_frequency) { - ret = radio_handle->intf.set_frequency(radio_handle->rh_handle, frequency); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal get_frequency is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_frequency) { + LOGW("radio_hal set_frequency is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.set_frequency(handle->rh_handle, frequency); } -int radio_hal_get_signal_strength(mm_radio_hal_interface *radio_handle, int32_t *strength) +int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.get_signal_strength) { - ret = radio_handle->intf.get_signal_strength(radio_handle->rh_handle, strength); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal get_signal_strength is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_signal_strength) { + LOGW("radio_hal get_signal_strength is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.get_signal_strength(handle->rh_handle, strength); } -int radio_hal_mute(mm_radio_hal_interface *radio_handle) +int radio_hal_mute(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.mute) { - ret = radio_handle->intf.mute(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal mute is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.mute) { + LOGW("radio_hal mute is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.mute(handle->rh_handle); } -int radio_hal_unmute(mm_radio_hal_interface *radio_handle) +int radio_hal_unmute(radio_hal_interface *handle) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.unmute) { - ret = radio_handle->intf.unmute(radio_handle->rh_handle); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal unmute is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.unmute) { + LOGW("radio_hal unmute is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + return handle->intf.unmute(handle->rh_handle); } -int radio_hal_set_volume(mm_radio_hal_interface *radio_handle, float volume) +int radio_hal_set_volume(radio_hal_interface *handle, float volume) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.set_volume) { - ret = radio_handle->intf.set_volume(radio_handle->rh_handle, volume); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal set_volume is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_volume) { + LOGW("radio_hal set_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + return handle->intf.set_volume(handle->rh_handle, volume); } -int radio_hal_get_volume(mm_radio_hal_interface *radio_handle, float *volume) +int radio_hal_get_volume(radio_hal_interface *handle, float *volume) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.get_volume) { - ret = radio_handle->intf.get_volume(radio_handle->rh_handle, volume); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal get_volume is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.get_volume) { + LOGW("radio_hal get_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + return handle->intf.get_volume(handle->rh_handle, volume); } -int radio_hal_set_media_volume(mm_radio_hal_interface *radio_handle, uint32_t level) +int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level) { - radio_error_t ret = RADIO_ERROR_NONE; - MMRADIO_CHECK_ARG(radio_handle); - if (radio_handle->intf.set_media_volume) { - ret = radio_handle->intf.set_media_volume(radio_handle->rh_handle, level); - if (ret != RADIO_ERROR_NONE) - return __convert_error_code(ret, (char *)__FUNCTION__); - } else { - MMRADIO_LOG_WARNING("radio_hal set_media_volume is NULL"); - return MM_ERROR_NOT_SUPPORT_API; + RADIO_INTF_CHECK_ARG(handle); + + if (!handle->intf.set_media_volume) { + LOGW("radio_hal set_media_volume is NULL"); + return RADIO_ERROR_NOT_IMPLEMENTED; } - return MM_ERROR_NONE; + + return handle->intf.set_media_volume(handle->rh_handle, level); } #ifdef __cplusplus