From 376a426ba3690fb0719437b9246afbdc42bb3fc1 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Fri, 24 Jul 2020 17:14:15 +0900 Subject: [PATCH] Add a checker whether engine is launched or not Change-Id: I8d49118dc17c4112cfce15b4a74856922f798669 Signed-off-by: sooyeon.kim --- client/tts.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/client/tts.c b/client/tts.c index d1ad656..79bd34d 100644 --- a/client/tts.c +++ b/client/tts.c @@ -56,7 +56,7 @@ static char g_engine_appid[256]; static int g_engine_update_status = 0; static pthread_mutex_t g_pkgmgr_mutex = PTHREAD_MUTEX_INITIALIZER; static Ecore_Thread* g_pkgmgr_thread = NULL; - +static bool __is_engine_launched(const char* appid); /* Function definition */ static Eina_Bool __tts_notify_state_changed(void *data); @@ -887,12 +887,17 @@ static Eina_Bool __tts_connect_daemon(void *data) return EINA_FALSE; } - /* check whether engine is updating or not */ - if (g_engine_update_status) { - SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update"); - __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + bool is_launched = __is_engine_launched(g_engine_appid); + SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts engine is launched(%d)", is_launched); - return EINA_FALSE; + if (false == is_launched) { + /* check whether engine is updating or not */ + if (g_engine_update_status) { + SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update"); + __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + + return EINA_FALSE; + } } /* Send hello */ @@ -1090,12 +1095,17 @@ static Eina_Bool __send_hello(void *data) SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); - /* check whether engine is updating or not */ - if (g_engine_update_status) { - SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update"); - __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - client->hello_timer = NULL; - return EINA_FALSE; + bool is_launched = __is_engine_launched(g_engine_appid); + SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts engine is launched(%d)", is_launched); + + if (false == is_launched) { + /* If engine is NOT launched, check whether engine is updating or not */ + if (g_engine_update_status) { + SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update"); + __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset"); + client->hello_timer = NULL; + return EINA_FALSE; + } } /* Send hello */ @@ -1112,7 +1122,7 @@ static Eina_Bool __send_hello(void *data) g_retry_cnt = 0; client->hello_timer = NULL; - bool is_launched = __is_engine_launched(g_engine_appid); + is_launched = __is_engine_launched(g_engine_appid); SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts engine is launched(%d)", is_launched); return EINA_FALSE; -- 2.7.4