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
/* 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;
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
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,
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;
* @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);
* @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);
* @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);
* @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()
* @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);
* @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);
* @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);
* @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);
* @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);
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);
&__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;
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;
}
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);
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;
}
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 */
MMRADIO_LOG_FLEAVE();
- return ret;
+ return MM_ERROR_NONE;
}
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;
}
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)
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;
}
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)
}
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 {
}
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;
}
#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 */
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;
}
}
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");
/* 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;
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);
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;
}
/* 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) {
} 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;
}
/* 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) {
*/
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;
}
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)
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;
}
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,
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);
#endif /* __cplusplus */
#include <dlfcn.h>
-#include "mm_radio_utils.h"
+#include <dlog.h>
+
#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);
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)
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;
}
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