Add mm_sound_client_request_unset_focus_watch_callback() to set a flag for skipping... 47/119547/5
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 17 Mar 2017 08:20:22 +0000 (17:20 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 20 Mar 2017 07:34:41 +0000 (16:34 +0900)
[Version] 0.10.103
[Profile] Common
[Issue Type] Enhancement

Change-Id: Ibf57ae5d51014cf353610f06c8e73379e915ff34
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/mm_sound_client.h
mm_sound_client.c
mm_sound_focus.c
packaging/libmm-sound.spec

index 1b37441..367d135 100644 (file)
@@ -68,6 +68,7 @@ int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, int option
 int mm_sound_client_update_stream_focus_status(int id, unsigned int status);
 int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* user_data, int *id);
 int mm_sound_client_unset_focus_watch_callback(int id);
+int mm_sound_client_request_unset_focus_watch_callback(int id);
 int mm_sound_client_execute_focus_func_in_main_context(focus_idle_event_type_e type, int data);
 #endif
 
index a8a3b8b..c1634f7 100644 (file)
@@ -99,6 +99,7 @@ typedef struct {
        mm_sound_focus_changed_cb focus_callback;
        mm_sound_focus_changed_watch_cb watch_callback;
        void* user_data;
+       bool unset_watch_callback_requested;
 
        bool is_for_session;    /* will be removed when the session concept is completely left out*/
 } focus_sound_info_t;
@@ -1272,17 +1273,22 @@ static gboolean _focus_watch_callback_handler(gpointer user_data)
                                tid, cb_data.handle,  cb_data.type, cb_data.state, cb_data.stream_type);
 
                if (focus_handle->watch_callback == NULL) {
-                       debug_msg("watch callback is null..");
-               } else {
-                       debug_msg("[CALLBACK(%p) START]", focus_handle->watch_callback);
-                       (focus_handle->watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type,
-                                                                               cb_data.ext_info, focus_handle->user_data);
-                       debug_msg("[CALLBACK END]");
-                       if (g_focus_session_interrupt_info.user_cb) {
-                               debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
-                               (g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, true,
-                                                                                                               g_focus_session_interrupt_info.user_data);
-                       }
+                       debug_warning("watch callback is null..");
+                       goto SKIP_CB_AND_RET;
+               }
+               if (focus_handle->unset_watch_callback_requested == true) {
+                       debug_warning("unset_watch_callback_requested..");
+                       goto SKIP_CB_AND_RET;
+               }
+
+               debug_msg("[CALLBACK(%p) START]", focus_handle->watch_callback);
+               (focus_handle->watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type,
+                                                                       cb_data.ext_info, focus_handle->user_data);
+               debug_msg("[CALLBACK END]");
+               if (g_focus_session_interrupt_info.user_cb) {
+                       debug_msg("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
+                       (g_focus_session_interrupt_info.user_cb)(cb_data.state, cb_data.stream_type, true,
+                                                                                                       g_focus_session_interrupt_info.user_data);
                }
 
 SKIP_CB_AND_RET:
@@ -1997,6 +2003,7 @@ int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e focu
        g_focus_sound_handle[index].watch_callback = callback;
        g_focus_sound_handle[index].user_data = user_data;
        g_focus_sound_handle[index].is_for_session = is_for_session;
+       g_focus_sound_handle[index].unset_watch_callback_requested = false;
 
        ret = mm_sound_proxy_set_focus_watch_callback(pid, g_focus_sound_handle[index].handle, focus_type,
                                                                                                callback, is_for_session, user_data);
@@ -2025,10 +2032,33 @@ cleanup:
        return ret;
 }
 
+int mm_sound_client_request_unset_focus_watch_callback(int id)
+{
+       int ret = MM_ERROR_NONE;
+       int index = -1;
+
+       debug_fenter();
+       MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
+
+       index = _focus_watch_find_index_by_handle(id);
+       if (index == -1) {
+               debug_error("Could not find index");
+               ret = MM_ERROR_INVALID_ARGUMENT;
+               goto cleanup;
+       }
+       g_focus_sound_handle[index].unset_watch_callback_requested = true;
+
+cleanup:
+       MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
+       debug_fleave();
+       return ret;
+}
+
 int mm_sound_client_unset_focus_watch_callback(int id)
 {
        int ret = MM_ERROR_NONE;
        int index = -1;
+
        debug_fenter();
        MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_index_mutex, MM_ERROR_SOUND_INTERNAL);
 
index 1bbee1a..70bac61 100644 (file)
@@ -466,12 +466,18 @@ int mm_sound_unset_focus_watch_callback(int id)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
+       if ((ret = mm_sound_client_request_unset_focus_watch_callback(id))) {
+               debug_error("failed to mm_sound_client_request_unset_focus_watch_callback, ret[0x%x]\n", ret);
+               return ret;
+       }
+
        mm_sound_client_is_focus_cb_thread(g_thread_self(), &result);
        if (!result) {
                if ((ret = mm_sound_client_unset_focus_watch_callback(id)))
                        debug_error("Could not unset focus watch callback, id(%d), ret[0x%x]\n", id, ret);
        } else {
                ret = mm_sound_client_execute_focus_func_in_main_context(IDLE_EVENT_TYPE_UNSET_FOCUS_WATCH_CB, id);
+               debug_msg("mm_sound_client_execute_focus_func_in_main_context() is called, id(%d), ret[0x%x]\n", id, ret);
        }
 
        debug_fleave();
index ed377cc..1e647e6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.102
+Version:    0.10.103
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0