From: Suyeon Hwang Date: Mon, 10 Apr 2023 09:06:35 +0000 (+0900) Subject: Add timer for callbacks in main loop X-Git-Tag: accepted/tizen/unified/20230411.161315~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65d4f917f9dc3bf7339a85a5610eebbe3d4144a1;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Add timer for callbacks in main loop - Issue: When the app calls setting API in sub-thread, the changed callback can not be invoked properly. - Solution: Most ecore API function properly works in main loop, and ecore_timer_add() is also a functions of this kind. Therefore, if the app calls setting API function in sub-thread, the changed event callbacks can not be invoked. To solve this issue, this patch changes the ecore timer registration logic. Through this patch, every timer will be added in main loop by ecore_main_loop_thread_safe_call_sync(). Change-Id: I8ce976cf2b86b1c2a309ea887f17f1641b9e3f01 Signed-off-by: Suyeon Hwang --- diff --git a/common/vc_config_mgr.cpp b/common/vc_config_mgr.cpp index 6977544..d45d930 100644 --- a/common/vc_config_mgr.cpp +++ b/common/vc_config_mgr.cpp @@ -142,8 +142,12 @@ static void notify_engine_changed(const char *engine_appid) return; } - delete_engine_changed_event_invoker(); - g_engine_changed_event_invoker = ecore_timer_add(0.0, notify_engine_changed_event_by_invoker, static_cast(param)); + ecore_main_loop_thread_safe_call_sync([](void *data) -> void * { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for engine changed event"); + delete_engine_changed_event_invoker(); + g_engine_changed_event_invoker = ecore_timer_add(0.0, notify_engine_changed_event_by_invoker, data); + return nullptr; + }, static_cast(param)); } static inline void release_language_changed_cb_params(language_changed_cb_parameters_s *params) @@ -215,8 +219,12 @@ static void notify_language_changed(const char* before_lang, const char* current params->before_lang = strdup(before_lang); params->current_lang = strdup(current_lang); - delete_language_changed_event_invoker(); - g_language_changed_event_invoker = ecore_timer_add(0.0, notify_language_changed_event_by_invoker, static_cast(params)); + ecore_main_loop_thread_safe_call_sync([](void *data) -> void * { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for language changed event"); + delete_language_changed_event_invoker(); + g_language_changed_event_invoker = ecore_timer_add(0.0, notify_language_changed_event_by_invoker, data); + return nullptr; + }, static_cast(params)); } static Eina_Bool notify_enabled_changed_event_by_invoker(void *data) @@ -270,8 +278,12 @@ static void notify_enabled_changed(bool enable) return; } - delete_enabled_changed_event_invoker(); - g_enabled_changed_event_invoker = ecore_timer_add(0.0, notify_enabled_changed_event_by_invoker, static_cast(param)); + ecore_main_loop_thread_safe_call_sync([](void *data) -> void * { + SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for enabled changed event"); + delete_enabled_changed_event_invoker(); + g_enabled_changed_event_invoker = ecore_timer_add(0.0, notify_enabled_changed_event_by_invoker, data); + return nullptr; + }, static_cast(param)); } static int initialize_config_info()