From: Gilbok Lee Date: Thu, 29 Mar 2018 10:43:09 +0000 (+0900) Subject: Unset the registered callbacks, after callbacks are called X-Git-Tag: accepted/tizen/unified/20180405.064327^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f74298a876811cb2937b337c426c39237bee3458;p=platform%2Fcore%2Fapi%2Fradio.git Unset the registered callbacks, after callbacks are called reset seek up/down, scan stop/finish callback [Version] 0.1.11 [Profile] Mobile, Wearable [Issue Type] Fix bugs Change-Id: I8e40ef622ab98834ce3d75bb567d56b4d1577351 --- diff --git a/packaging/capi-media-radio.spec b/packaging/capi-media-radio.spec index a01f198..ceb488c 100644 --- a/packaging/capi-media-radio.spec +++ b/packaging/capi-media-radio.spec @@ -1,6 +1,6 @@ Name: capi-media-radio Summary: A Radio library in Tizen Native API -Version: 0.1.10 +Version: 0.1.11 Release: 1 Group: API/C API License: Apache-2.0 diff --git a/src/radio.c b/src/radio.c index 324c909..f3cff56 100644 --- a/src/radio.c +++ b/src/radio.c @@ -178,7 +178,7 @@ static int __set_callback(_radio_event_e type, radio_h radio, void *callback, vo radio_s *handle = (radio_s *)radio; handle->user_cb[type] = callback; handle->user_data[type] = user_data; - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("[%s] Event type : %d", __FUNCTION__, type); return RADIO_ERROR_NONE; } @@ -188,7 +188,7 @@ static int __unset_callback(_radio_event_e type, radio_h radio) radio_s *handle = (radio_s *)radio; handle->user_cb[type] = NULL; handle->user_data[type] = NULL; - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + LOGI("[%s] Event type : %d", __FUNCTION__, type); return RADIO_ERROR_NONE; } @@ -205,16 +205,20 @@ static int __msg_callback(int message, void *param, void *user_data) case MM_MESSAGE_RADIO_SCAN_STOP: if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP]) ((radio_scan_stopped_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_STOP]); + __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP, (radio_h)handle); + __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, (radio_h)handle); break; case MM_MESSAGE_RADIO_SCAN_FINISH: if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH]) ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]); + __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, (radio_h)handle); break; case MM_MESSAGE_RADIO_SEEK_FINISH: if (handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH]) { ((radio_seek_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SEEK_FINISH]); handle->seeking = false; } + __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, (radio_h)handle); break; case MM_MESSAGE_STATE_INTERRUPTED: if (msg->union_type == MM_MSG_UNION_STATE) { @@ -444,9 +448,9 @@ int radio_set_frequency(radio_h radio, int frequency) LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER); return RADIO_ERROR_INVALID_PARAMETER; } - int freq = frequency; + radio_s *handle = (radio_s *)radio; - int ret = mm_radio_set_frequency(handle->mm_handle, freq); + int ret = mm_radio_set_frequency(handle->mm_handle, frequency); if (ret != MM_ERROR_NONE) return __convert_error_code(ret, (char *)__FUNCTION__); else @@ -518,6 +522,11 @@ int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_da 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); + return RADIO_ERROR_INVALID_OPERATION; + } + if (callback != NULL) __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio, callback, user_data); else @@ -632,9 +641,9 @@ int radio_set_volume(radio_h radio, float volume) LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER); return RADIO_ERROR_INVALID_PARAMETER; } - float vol = volume; + radio_s *handle = (radio_s *)radio; - int ret = mm_radio_set_volume(handle->mm_handle, vol); + int ret = mm_radio_set_volume(handle->mm_handle, volume); if (ret != MM_ERROR_NONE) return __convert_error_code(ret, (char *)__FUNCTION__); else