static GList *g_proc_list = NULL;
static Ecore_Timer *g_restart_timer = NULL;
+static Ecore_Timer *g_check_widget_client_timer = NULL;
/**
* @brief Enumerations of send event type.
int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
{
+ int ret = __vcd_server_launch_manager_app();
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ return ret;
+ }
+
if (NULL != asr_result) {
SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
- vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ ret = vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ }
}
- return VCD_ERROR_NONE;
+ return ret;
}
int vcd_send_nlg_result(const char* nlg_result, void *user_data)
char* error_msg = NULL;
if (NULL != msg) {
error_msg = strdup(msg);
+ if (NULL == error_msg) {
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
}
- if (0 != vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg)) {
+ int ret = VCD_ERROR_NONE;
+ ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+ if (VCD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
}
error_msg = NULL;
}
- return VCD_ERROR_NONE;
+ return ret;
}
/*
return 0;
}
-void vcd_finalize()
+bool vcd_finalize()
{
GList *iter = NULL;
if (0 < g_list_length(g_proc_list)) {
}
vcd_engine_recognize_cancel();
}
+
if (0 != vcd_recorder_destroy()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to destroy recorder");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] destroy recorder");
}
if (0 != vcd_engine_agent_release()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to release engine");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine");
}
SLOG(LOG_ERROR, TAG_VCD, "[Server] mode finalize");
- return;
+ return true;
}
static Eina_Bool __finalize_quit_ecore_loop(void *data)
{
- SLOG(LOG_ERROR, TAG_VCD, "[Server] quit ecore main loop");
- ecore_main_loop_quit();
- return EINA_FALSE;
+ bool ret = vcd_finalize();
+ if (false == ret) {
+ return EINA_TRUE;
+ } else {
+ ecore_main_loop_quit();
+ return EINA_FALSE;
+ }
}
static void __read_proc()
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
+static int __reset_waiting_for_widget_recording(void)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Reet waiting for widget recording");
+ // Delete timer to check that widget client is terminated
+ if (g_check_widget_client_timer) {
+ ecore_timer_del(g_check_widget_client_timer);
+ g_check_widget_client_timer = NULL;
+ }
+ // Reset flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(-1, false);
+ return 0;
+}
+
+static Eina_Bool __send_waiting_timeout_error_to_manager(void* data)
+{
+ intptr_t ppid = (intptr_t)data;
+ int pid = (int)ppid;
+ SLOG(LOG_ERROR, TAG_VCD, "Widget client didn't send to start recording, pid(%d)", pid);
+ __reset_waiting_for_widget_recording();
+
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
+ return EINA_FALSE;
+}
+
+static int __set_waiting_for_widget_recording(int pid)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Set waiting for widget recording, pid(%d)", pid);
+
+ // Check if the app included widget client is terminated or not. If it is terminated, vcd_server_widget_finalize() function will be called
+ // In that function, it will start recording
+ intptr_t ppid = (intptr_t)pid;
+ g_check_widget_client_timer = ecore_timer_add(2.0, __send_waiting_timeout_error_to_manager, (void*)ppid);
+
+ // Set flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(pid, true);
+ return 0;
+}
+
static int __start_internal_recognition()
{
int ret;
+ __reset_waiting_for_widget_recording();
if (0 != vcd_client_command_collect_command()) {
SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command");
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
}
- vcd_client_widget_set_waiting_for_recording(-1, false);
+ __reset_waiting_for_widget_recording();
SLOG(LOG_ERROR, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode);
vcd_client_set_recognition_mode(recognition_mode);
if (-1 != pid) {
SLOG(LOG_ERROR, 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);
+
+ __set_waiting_for_widget_recording(pid);
return 0;
}
}
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Client Finalize : pid(%d)", pid);
static void __vcd_server_widget_start_recording(void *data)
{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] start recording");
+
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)
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
return 0;
}
}
if (true == is_waiting) {
- SLOG(LOG_INFO, TAG_VCD, "[Server INFO] invoke to start recording");
+ SLOG(LOG_ERROR, 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_INVALID_PARAMETER;
}
+ bool waiting;
+ if (0 != vcd_client_widget_get_waiting_for_recording(pid, &waiting) || false == waiting) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Server is not waiting for recording, pid(%d), waiting(%d)", pid, waiting);
+ return 0;
+ }
+
if (true == widget_command) {
vcd_client_widget_set_command(pid);
SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is available");