Add checking if it is seeking to avoid callback override. 89/156089/1 accepted/tizen/4.0/unified/20171018.060713 submit/tizen_4.0/20171017.071842 tizen_4.0.IoT.p2_release tizen_4.0.m2_release
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 17 Oct 2017 05:30:36 +0000 (14:30 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 17 Oct 2017 06:19:00 +0000 (15:19 +0900)
[Version] 0.1.9
[Profile] Mobile, Wearable
[Issue Type] Fix bugs

Change-Id: I2b13a3b08d42070a55cff525bb69e1deb18016d5

include/radio_private.h
packaging/capi-media-radio.spec
src/radio.c

index edb4a3e..33ad713 100644 (file)
@@ -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
index ce24b39..8b711c3 100644 (file)
@@ -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
index 99c8413..324c909 100644 (file)
@@ -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