Skip invoking watch callback if the request is coming from the watch callback 80/129380/4
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 16 May 2017 05:10:43 +0000 (14:10 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 29 May 2017 02:17:35 +0000 (11:17 +0900)
It is possible that request of acquiring/releasing focus can be executed within
focus watch callback. In this case, focus server can try to invoke the focus
watch callback of same node again based on conditions and then it gets blocked.
This patch avoids situation by skipping the callback again.

[Version] 0.11.2
[Issue Type] Enhancement

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

index 4d4d144..d8dfcb2 100644 (file)
@@ -85,6 +85,7 @@ typedef struct {
        _focus_taken_by_id_t taken_backup[NUM_OF_STREAM_IO_TYPE];
        void *callback;
        void *cbdata;
+       bool during_cb;
        bool reacquisition;
 
        /* These will be removed when the session concept is completely left out*/
index bee6098..e8f67d7 100644 (file)
@@ -233,6 +233,7 @@ static void _invoke_watch_callback(focus_node_t *node, const char *stream_type,
        cb_data.state = (command == FOCUS_COMMAND_ACQUIRE) ? !FOCUS_STATUS_DEACTIVATED : FOCUS_STATUS_DEACTIVATED;
        MMSOUND_STRNCPY(cb_data.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
        MMSOUND_STRNCPY(cb_data.ext_info, param->ext_info, MM_SOUND_NAME_NUM);
+       node->during_cb = true;
 
        /* Set start time */
        gettimeofday(&time, NULL);
@@ -317,6 +318,8 @@ static void _invoke_watch_callback(focus_node_t *node, const char *stream_type,
         *
         **************************************/
 RELEASE:
+       node->during_cb = false;
+
        g_free(filename);
        filename = NULL;
 
@@ -421,6 +424,10 @@ static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_
                        continue;
                if (node->is_for_monitor)
                        continue;
+               if (node->during_cb) {
+                       debug_msg("it is about to invoke watch callback again during processing it, skip it");
+                       continue;
+               }
 
                _invoke_watch_callback(node, my_node->stream_type, focus_type, command, param);
        }
index b2d362c..c05ae53 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.11.1
+Version:    0.11.2
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0