do { \
if (condition) { \
} else { \
- LOGE("[%s] %s(0x%08x)", (char *)__FUNCTION__, msg, error); \
+ LOGE("%s(0x%08x)", msg, error); \
return error; \
} \
} while (0)
{
int ret = RADIO_ERROR_NONE;
char *msg = "RADIO_ERROR_NONE";
- LOGI("[%s] Enter code :%x", __func__, code);
+ LOGI("Enter code :%x", code);
switch (code) {
case MM_ERROR_NONE:
ret = RADIO_ERROR_NONE;
msg = "RADIO_ERROR_NONE";
break;
-
case MM_ERROR_RADIO_NO_FREE_SPACE:
+ case MM_ERROR_OUT_OF_MEMORY:
ret = RADIO_ERROR_OUT_OF_MEMORY;
msg = "RADIO_ERROR_OUT_OF_MEMORY";
break;
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";
msg = "RADIO_ERROR_NO_ANTENNA";
break;
case MM_ERROR_RADIO_DEVICE_NOT_OPENED:
- default:
+ case MM_ERROR_RADIO_PERMISSION_DENIED:
ret = RADIO_ERROR_PERMISSION_DENIED;
msg = "RADIO_ERROR_PERMISSION_DENIED";
+ break;
+ case MM_ERROR_NOT_IMPLEMENTED:
+ case MM_ERROR_RADIO_INTERNAL:
+ case MM_ERROR_RADIO_RESPONSE_TIMEOUT:
+ default:
+ ret = RADIO_ERROR_INVALID_OPERATION;
+ msg = "RADIO_ERROR_INVALID_OPERATION";
+ break;
}
LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
return ret;
static radio_state_e __convert_radio_state(MMRadioStateType state)
{
int converted_state = RADIO_STATE_READY;
- LOGI("[%s] Enter state: %d", __func__, state);
+ LOGI("Enter state: %d", state);
switch (state) {
case MM_RADIO_STATE_PLAYING:
converted_state = RADIO_STATE_READY;
break;
}
- LOGI("[%s] Leave converted_state: %d", __func__, converted_state);
+ LOGI("Leave converted_state: %d", converted_state);
return converted_state;
}
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("Event type : %d", type);
return RADIO_ERROR_NONE;
}
radio_s *handle = (radio_s *)radio;
handle->user_cb[type] = NULL;
handle->user_data[type] = NULL;
- LOGI("[%s] Event type : %d", __FUNCTION__, type);
+ LOGI("Event type : %d", type);
return RADIO_ERROR_NONE;
}
{
radio_s *handle = (radio_s *)user_data;
MMMessageParamType *msg = (MMMessageParamType *)param;
- LOGI("[%s] Got message type : 0x%x", __FUNCTION__, message);
+ LOGI("Got message type : 0x%x", message);
switch (message) {
case MM_MESSAGE_RADIO_SCAN_INFO:
if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])
__convert_error_code(msg->code, (char *)__FUNCTION__);
break;
case MM_MESSAGE_RADIO_SCAN_START:
- LOGI("[%s] Scan Started", __FUNCTION__);
+ LOGI("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);
+ LOGI("State Changed --- from : %d , to : %d", __convert_radio_state(msg->state.previous), handle->state);
break;
case MM_MESSAGE_RADIO_SEEK_START:
- LOGI("[%s] Seek Started", __FUNCTION__);
+ LOGI("Seek Started");
break;
default:
break;
static int __radio_check_system_info_feature_supported()
{
- bool bValue = false;
- int nRetVal = false;
+ bool val = false;
+ int ret = false;
- nRetVal = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &bValue);
+ ret = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &val);
- if (nRetVal != SYSTEM_INFO_ERROR_NONE) {
- LOGE("[%s] SYSTEM_INFO_ERROR : ", __FUNCTION__);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ LOGE("SYSTEM_INFO_ERROR");
return false;
}
- if (false == bValue)
- LOGI("system_info_get_platform_bool returned Unsupported feature capability\n");
+ if (val == false)
+ LOGI("system_info_get_platform_bool returned Unsupported feature capability");
else
- LOGI("system_info_get_platform_bool returned Supported status feature\n");
+ LOGI("system_info_get_platform_bool returned Supported status feature");
- return bValue;
+ return val;
}
/*
*/
int radio_create(radio_h *radio)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle;
handle = (radio_s *)malloc(sizeof(radio_s));
- if (handle != NULL) {
- memset(handle, 0, sizeof(radio_s));
- } else {
- LOGE("[%s] RADIO_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, RADIO_ERROR_OUT_OF_MEMORY);
+ if (!handle) {
+ LOGE("RADIO_ERROR_OUT_OF_MEMORY(0x%08x)", RADIO_ERROR_OUT_OF_MEMORY);
return RADIO_ERROR_OUT_OF_MEMORY;
}
+
+ memset(handle, 0, sizeof(radio_s));
+
int ret = mm_radio_create(&handle->mm_handle);
if (ret != MM_ERROR_NONE) {
free(handle);
handle = NULL;
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- *radio = (radio_h)handle;
+ }
+
+ *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("Failed to set message callback function (0x%x)", ret);
- ret = mm_radio_realize(handle->mm_handle);
- if (ret != MM_ERROR_NONE)
- return __convert_error_code(ret, (char *)__FUNCTION__);
+ ret = mm_radio_realize(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
+ return __convert_error_code(ret, (char *)__FUNCTION__);
- handle->state = RADIO_STATE_READY;
- handle->mute = false;
- handle->seeking = false;
- return RADIO_ERROR_NONE;
- }
+ handle->state = RADIO_STATE_READY;
+ handle->mute = false;
+ handle->seeking = false;
+ return RADIO_ERROR_NONE;
}
int radio_destroy(radio_h radio)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle = (radio_s *)radio;
int ret;
ret = mm_radio_unrealize(handle->mm_handle);
if (ret != MM_ERROR_NONE)
- LOGW("[%s] Failed to unrealize (0x%x)", __FUNCTION__, ret);
+ LOGW("Failed to unrealize (0x%x)", ret);
ret = mm_radio_destroy(handle->mm_handle);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- free(handle);
- handle = NULL;
- return RADIO_ERROR_NONE;
- }
+
+ free(handle);
+ handle = NULL;
+ return RADIO_ERROR_NONE;
}
int radio_get_state(radio_h radio, radio_state_e *state)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(state);
if (ret != MM_ERROR_NONE) {
*state = handle->state;
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- handle->state = __convert_radio_state(currentStat);
- *state = handle->state;
- return RADIO_ERROR_NONE;
}
+
+ handle->state = __convert_radio_state(currentStat);
+ *state = handle->state;
+ return RADIO_ERROR_NONE;
}
int radio_start(radio_h radio)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
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);
int ret = mm_radio_start(handle->mm_handle);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- handle->state = RADIO_STATE_PLAYING;
- return RADIO_ERROR_NONE;
- }
+
+ handle->state = RADIO_STATE_PLAYING;
+ return RADIO_ERROR_NONE;
}
int radio_stop(radio_h radio)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
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);
int ret = mm_radio_stop(handle->mm_handle);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- handle->state = RADIO_STATE_READY;
- return RADIO_ERROR_NONE;
- }
+
+ handle->state = RADIO_STATE_READY;
+ return RADIO_ERROR_NONE;
}
int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle = (radio_s *)radio;
int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_UP);
if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle = (radio_s *)radio;
int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_DOWN);
if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_set_frequency(radio_h radio, int frequency)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
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);
+ LOGE("RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)", RADIO_ERROR_INVALID_PARAMETER);
return RADIO_ERROR_INVALID_PARAMETER;
}
int ret = mm_radio_set_frequency(handle->mm_handle, frequency);
if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_get_frequency(radio_h radio, int *frequency)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(frequency);
int freq;
int ret = mm_radio_get_frequency(handle->mm_handle, &freq);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- *frequency = freq;
- return RADIO_ERROR_NONE;
- }
+
+ *frequency = freq;
+ return RADIO_ERROR_NONE;
}
int radio_get_signal_strength(radio_h radio, int *strength)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(strength);
int _strength;
int ret = mm_radio_get_signal_strength(handle->mm_handle, &_strength);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- *strength = _strength;
- return RADIO_ERROR_NONE;
- }
+
+ *strength = _strength;
+ return RADIO_ERROR_NONE;
}
int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle = (radio_s *)radio;
__unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio);
int ret = mm_radio_scan_start(handle->mm_handle);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- handle->state = RADIO_STATE_SCANNING;
- return RADIO_ERROR_NONE;
- }
+
+ handle->state = RADIO_STATE_SCANNING;
+ return RADIO_ERROR_NONE;
+
}
int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
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);
if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP]) {
- LOGW("[%s] Failed to stop scan (0x%x)", __FUNCTION__, RADIO_ERROR_INVALID_OPERATION);
+ LOGW("Failed to stop scan (0x%x)", RADIO_ERROR_INVALID_OPERATION);
return RADIO_ERROR_INVALID_OPERATION;
}
int ret = mm_radio_scan_stop(handle->mm_handle);
if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_set_mute(radio_h radio, bool muted)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
radio_s *handle = (radio_s *)radio;
int ret = mm_radio_set_mute(handle->mm_handle, muted);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- handle->mute = muted;
- return RADIO_ERROR_NONE;
- }
+
+ handle->mute = muted;
+ return RADIO_ERROR_NONE;
+
}
int radio_is_muted(radio_h radio, bool *muted)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(muted);
int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
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__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
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__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio, callback, user_data);
}
int radio_unset_interrupted_cb(radio_h radio)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
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__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(min_freq);
unsigned int max = 0;
int ret = mm_radio_get_region_frequency_range(handle->mm_handle, &min, &max);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- *min_freq = min;
- *max_freq = max;
- return RADIO_ERROR_NONE;
- }
+
+ *min_freq = min;
+ *max_freq = max;
+ return RADIO_ERROR_NONE;
}
int radio_get_channel_spacing(radio_h radio, int *channel_spacing)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(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__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_set_volume(radio_h radio, float volume)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
if (volume < 0.0 || volume > 1.0) {
- LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER);
+ LOGE("RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", RADIO_ERROR_INVALID_PARAMETER);
return RADIO_ERROR_INVALID_PARAMETER;
}
int ret = mm_radio_set_volume(handle->mm_handle, volume);
if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- else
- return RADIO_ERROR_NONE;
+
+ return RADIO_ERROR_NONE;
}
int radio_get_volume(radio_h radio, float *volume)
{
- LOGI("[%s] Enter", __func__);
+ LOGI("Enter");
RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
RADIO_INSTANCE_CHECK(radio);
RADIO_NULL_ARG_CHECK(volume);
float vol;
int ret = mm_radio_get_volume(handle->mm_handle, &vol);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return __convert_error_code(ret, (char *)__FUNCTION__);
- } else {
- *volume = vol;
- return RADIO_ERROR_NONE;
- }
-}
+ *volume = vol;
+ return RADIO_ERROR_NONE;
+}