Start recording when widget finalize 62/166262/1
authorWonnam Jang <wn.jang@samsung.com>
Thu, 4 Jan 2018 23:27:23 +0000 (08:27 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 9 Jan 2018 05:05:36 +0000 (05:05 +0000)
Change-Id: Ifd2e55fca66daa235d43cc995ecc30419f2f7652
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
(cherry picked from commit 9d6162c6d676bc3f674143ec7f6c979df2680423)

server/vcd_client_data.c
server/vcd_client_data.h
server/vcd_server.c

index 56b95b6..c18b8b2 100644 (file)
@@ -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_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);
 
 /* 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;
 }
 
        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;
 void vcd_client_update_foreground_pid()
 {
        int tmp_pid = VC_RUNTIME_INFO_NO_FOREGROUND;
index d38a8ba..ae57883 100644 (file)
@@ -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_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
 #ifdef __cplusplus
 }
 #endif
index 9897853..d6b6155 100755 (executable)
@@ -1076,7 +1076,7 @@ void vcd_finalize()
 
 static Eina_Bool __finalize_quit_ecore_loop(void *data)
 {
 
 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;
 }
        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;
        }
                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);
 
        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);
                        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;
                        }
                }
                                return 0;
                        }
                }
@@ -2193,6 +2195,14 @@ int vcd_server_widget_initialize(int pid)
        return VCD_ERROR_NONE;
 }
 
        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 */
 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()) {
        }
 
        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);
                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;
 }
 
        return VCD_ERROR_NONE;
 }