From 85e9da10e814a610cf5dfbe9fdb4356ef4fe7331 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Tue, 16 May 2017 14:10:43 +0900 Subject: [PATCH] Skip invoking watch callback if the request is coming from the watch callback 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 --- focus_server/include/mm_sound_mgr_focus.h | 1 + focus_server/mm_sound_mgr_focus.c | 7 +++++++ packaging/libmm-sound.spec | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/focus_server/include/mm_sound_mgr_focus.h b/focus_server/include/mm_sound_mgr_focus.h index 4d4d144..d8dfcb2 100644 --- a/focus_server/include/mm_sound_mgr_focus.h +++ b/focus_server/include/mm_sound_mgr_focus.h @@ -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*/ diff --git a/focus_server/mm_sound_mgr_focus.c b/focus_server/mm_sound_mgr_focus.c index bee6098..e8f67d7 100644 --- a/focus_server/mm_sound_mgr_focus.c +++ b/focus_server/mm_sound_mgr_focus.c @@ -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); } diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index b2d362c..c05ae53 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -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 -- 2.7.4