From: Gilbok Lee Date: Tue, 17 Oct 2017 05:30:36 +0000 (+0900) Subject: Add checking if it is seeking to avoid callback override. X-Git-Tag: accepted/tizen/4.0/unified/20171018.060713^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cc2a59e541eb3ca24c5c286372e6b36d2ca2536;p=platform%2Fcore%2Fapi%2Fradio.git Add checking if it is seeking to avoid callback override. [Version] 0.1.9 [Profile] Mobile, Wearable [Issue Type] Fix bugs Change-Id: I2b13a3b08d42070a55cff525bb69e1deb18016d5 --- diff --git a/include/radio_private.h b/include/radio_private.h index edb4a3e..33ad713 100644 --- a/include/radio_private.h +++ b/include/radio_private.h @@ -38,6 +38,7 @@ typedef struct _radio_s { void *user_data[_RADIO_EVENT_TYPE_NUM]; radio_state_e state; bool mute; + bool seeking; } radio_s; #ifdef __cplusplus diff --git a/packaging/capi-media-radio.spec b/packaging/capi-media-radio.spec index ce24b39..8b711c3 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.8 +Version: 0.1.9 Release: 1 Group: API/C API License: Apache-2.0 diff --git a/src/radio.c b/src/radio.c index 99c8413..324c909 100644 --- a/src/radio.c +++ b/src/radio.c @@ -211,8 +211,10 @@ static int __msg_callback(int message, void *param, void *user_data) ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]); break; case MM_MESSAGE_RADIO_SEEK_FINISH: - if (handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH]) + 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; + } break; case MM_MESSAGE_STATE_INTERRUPTED: if (msg->union_type == MM_MSG_UNION_STATE) { @@ -298,7 +300,8 @@ int radio_create(radio_h *radio) return __convert_error_code(ret, (char *)__FUNCTION__); handle->state = RADIO_STATE_READY; - handle->mute = FALSE; + handle->mute = false; + handle->seeking = false; return RADIO_ERROR_NONE; } } @@ -386,6 +389,13 @@ int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_da radio_s *handle = (radio_s *)radio; RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING); + if (handle->seeking) { + LOGI("radio is seeking, can't serve another request try again"); + return RADIO_ERROR_INVALID_OPERATION; + } + + handle->seeking = true; + if (callback != NULL) __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data); else @@ -406,6 +416,13 @@ int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_ radio_s *handle = (radio_s *)radio; RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING); + if (handle->seeking) { + LOGI("radio is seeking, can't serve another request try again"); + return RADIO_ERROR_INVALID_OPERATION; + } + + handle->seeking = true; + if (callback != NULL) __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data); else