From: Seungbae Shin Date: Mon, 23 Sep 2024 08:57:09 +0000 (+0900) Subject: focus-server: wait for callback completion before removing focus pipe X-Git-Tag: accepted/tizen/unified/20240924.005952^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_dev;p=platform%2Fcore%2Fmultimedia%2Flibmm-sound.git focus-server: wait for callback completion before removing focus pipe The wait timeout is set same as other callback timeout (2500ms) [Version] 0.14.4 [Issue Type] Robustness Change-Id: I3ea6b397e026fcada087abdf55172f389a8fead1 --- diff --git a/focus_server/mm_sound_mgr_focus.c b/focus_server/mm_sound_mgr_focus.c index 161e735..e01aed7 100644 --- a/focus_server/mm_sound_mgr_focus.c +++ b/focus_server/mm_sound_mgr_focus.c @@ -36,11 +36,14 @@ #include #define CALLBACK_TIMEOUT 2500 /* millisecond */ +#define INVOKE_CHECK_INTERVAL_MS 30 static GList *g_focus_node_list = NULL; static pthread_mutex_t g_focus_node_list_mutex = PTHREAD_MUTEX_INITIALIZER; static stream_list_t g_stream_list; +static gint g_on_invoke_ref; + static const char* focus_status_str[] = { "DEACTIVATED", "P ACTIVATED", @@ -111,10 +114,34 @@ static void __remove_focus_pipe(focus_node_t *node, bool is_return) debug_log("focus-pipe(%s) removed", filename); } +static void __wait_for_callback_completion(void) +{ + unsigned int retry_count = 0; + + debug_fenter(); + + /* wait for watch invoke completion or timeout(2500ms) */ + while (g_atomic_int_get(&g_on_invoke_ref) > 0) { + usleep(INVOKE_CHECK_INTERVAL_MS * 1000); + + if (INVOKE_CHECK_INTERVAL_MS * retry_count++ > CALLBACK_TIMEOUT) { + debug_warning("timeout for callback completion, still remaining of %d", g_atomic_int_get(&g_on_invoke_ref)); + return; + } + } + + debug_msg("wait done, retry_count[%d]", retry_count); + + debug_fleave(); +} + + static void __clear_focus_pipe(focus_node_t *node) { debug_fenter(); + __wait_for_callback_completion(); + __remove_focus_pipe(node, false); __remove_focus_pipe(node, true); @@ -320,6 +347,8 @@ static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_ return MM_ERROR_INVALID_ARGUMENT; } + g_atomic_int_inc(&g_on_invoke_ref); + for (list = g_focus_node_list; list != NULL; list = list->next) { SET_NODE_FROM_LIST_DATA(node, list); if (node == my_node) @@ -334,6 +363,12 @@ static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_ _invoke_watch_callback(node, my_node->stream_type, focus_type, command, param); } + if (g_atomic_int_dec_and_test(&g_on_invoke_ref)) { + debug_msg("no remaining watch invoke"); + } else { + debug_warning("still watch invoke remains in other place"); + } + debug_fleave(); return MM_ERROR_NONE; diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index 2e53a75..a265a8e 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 focus server binary -Version: 0.14.3 +Version: 0.14.4 Release: 0 Group: System/Libraries License: Apache-2.0