From: Suyeon Hwang Date: Fri, 7 Jan 2022 07:35:08 +0000 (+0900) Subject: Call service state changed callback before state changed callback X-Git-Tag: submit/tizen/20220208.060036~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=877a5b40910fa1a85d23585cb3ef87fbfc1e7913;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Call service state changed callback before state changed callback https://review.tizen.org/gerrit/c/platform/core/uifw/voice-control/+/223267 The patch of this link makes that service state changed callback is called asynchronously. This was because prepare process was handled on sub thread. In order to assure the callback calls on main thread, the patch seperated the code for calling service state changed callback and state changed callback. However, this change made client can not assure the value of service state because it was updated unknown timing. To solve this problem, this patch calls the service state changed callback before calling the state changed callback. Current code does not handle the prepare process on sub thread but on main thread. So, by this change, service state would be synchornously updated when the state changed callback is called. Change-Id: I276577fb494a93c8e4f58182c2e16a6ff88b7423 Signed-off-by: Suyeon Hwang --- diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 0c82dc8..9c07f62 100755 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -457,6 +457,24 @@ static Eina_Bool __request_initialize(void *data) /* Success to connect */ } + /* Set service state */ + vc_service_state_e previous_service_state; + vc_mgr_client_get_service_state(g_vc_m, &previous_service_state); + vc_mgr_client_set_service_state(g_vc_m, (vc_service_state_e)service_state); + + vc_service_state_changed_cb service_changed_callback = NULL; + void* user_data = NULL; + vc_mgr_client_get_service_state_changed_cb(g_vc_m, &service_changed_callback, &user_data); + + if (NULL != service_changed_callback) { + vc_mgr_client_use_callback(g_vc_m); + service_changed_callback(previous_service_state, service_state, user_data); + vc_mgr_client_not_use_callback(g_vc_m); + SLOG(LOG_INFO, TAG_VCM, "Service state changed callback is called"); + } else { + SLOG(LOG_WARN, TAG_VCM, "[WARNING] Service state changed callback is null"); + } + /* Set foreground */ vc_mgr_client_set_foreground(g_vc_m, foreground, true); @@ -466,7 +484,7 @@ static Eina_Bool __request_initialize(void *data) vc_mgr_client_set_client_state(g_vc_m, VC_STATE_READY); vc_state_changed_cb changed_callback = NULL; - void* user_data = NULL; + user_data = NULL; vc_mgr_client_get_state_changed_cb(g_vc_m, &changed_callback, &user_data); vc_state_e current_state; diff --git a/server/vcd_server.c b/server/vcd_server.c index 81cbd50..faf41e5 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1673,16 +1673,6 @@ int vcd_server_get_foreground() return pid; } -static Eina_Bool __vcd_send_service_state(void *data) -{ - vcd_config_set_service_state(VCD_STATE_READY); - vcdc_send_service_state(VCD_STATE_READY); - - SLOG(LOG_INFO, TAG_VCD, "[Server Success] success to send service status for READY"); - - return EINA_FALSE; -} - /* * API for manager */ @@ -1707,8 +1697,6 @@ int vcd_server_mgr_initialize(int pid, vcd_audio_streaming_mode_e mode) vcd_recorder_set_audio_streaming_mode(mode); - ecore_timer_add(0.05, __vcd_send_service_state, NULL); - SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid); return VCD_ERROR_NONE;