From 04db28d264c560257bba8c9e834809022f2391b5 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Fri, 5 Jan 2018 08:27:23 +0900 Subject: [PATCH] Start recording when widget finalize Change-Id: Ifd2e55fca66daa235d43cc995ecc30419f2f7652 Signed-off-by: Wonnam Jang (cherry picked from commit 9d6162c6d676bc3f674143ec7f6c979df2680423) --- server/vcd_client_data.c | 28 ++++++++++++++++++++++++++++ server/vcd_client_data.h | 5 +++++ server/vcd_server.c | 24 ++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 56b95b6..c18b8b2 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -39,6 +39,8 @@ static GSList* g_demandable_client = NULL; static bool g_silence_detection; static vcd_recognition_mode_e g_recognition_mode; static char* g_result_text = NULL; +static bool g_is_waiting_recording = false; +static int g_waiting_recording_pid = -1; /* Function definitions */ widget_info_s* __widget_get_element(int pid); @@ -1401,6 +1403,32 @@ int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) return 0; } +int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) +{ + + if (TRUE == waiting && pid != vcd_client_widget_get_foreground_pid()) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT forground pid", pid); + return -1; + } + + g_is_waiting_recording = waiting; + g_waiting_recording_pid = pid; + SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting); + return 0; +} + +int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting) +{ + if (pid != g_waiting_recording_pid) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT waiting pid", pid); + return -1; + } + + *waiting = g_is_waiting_recording; + SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting); + return 0; +} + void vcd_client_update_foreground_pid() { int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND; diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index d38a8ba..ae57883 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -174,6 +174,11 @@ int vcd_client_widget_set_asr_result_enabled(int pid, bool enable); int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable); +int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting); + +int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting); + + #ifdef __cplusplus } #endif diff --git a/server/vcd_server.c b/server/vcd_server.c index 9897853..d6b6155 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1076,7 +1076,7 @@ void vcd_finalize() static Eina_Bool __finalize_quit_ecore_loop(void *data) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] quit ecore main loop"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] quit ecore main loop"); ecore_main_loop_quit(); return EINA_FALSE; } @@ -1554,6 +1554,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } + vcd_client_widget_set_waiting_for_recording(-1, false); SLOG(LOG_DEBUG, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode); vcd_client_set_recognition_mode(recognition_mode); @@ -1566,6 +1567,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive if (-1 != pid) { SLOG(LOG_INFO, TAG_VCD, "[Server] Request tooltip show and widget command"); ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); + vcd_client_widget_set_waiting_for_recording(pid, true); return 0; } } @@ -2193,6 +2195,14 @@ int vcd_server_widget_initialize(int pid) return VCD_ERROR_NONE; } +static void __vcd_server_widget_start_recording(void *data) +{ + if (0 != __start_internal_recognition()) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition"); + } + vcd_client_widget_set_waiting_for_recording(-1, false); +} + int vcd_server_widget_finalize(int pid) { /* check if pid is valid */ @@ -2207,10 +2217,20 @@ int vcd_server_widget_finalize(int pid) } if (0 == vcd_client_get_ref_count()) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] connected client list is empty"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + return 0; + } + + bool is_waiting = false; + if (0 != vcd_client_widget_get_waiting_for_recording(pid, &is_waiting)) { + SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get waiting to recording"); } + if (true == is_waiting) { + SLOG(LOG_INFO, TAG_VCD, "[Server INFO] invoke to start recording"); + ecore_main_loop_thread_safe_call_async(__vcd_server_widget_start_recording, NULL); + } return VCD_ERROR_NONE; } -- 2.34.1