Add a checker whether engine is launched or not 70/239370/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 08:14:15 +0000 (17:14 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 08:14:15 +0000 (17:14 +0900)
Change-Id: I8d49118dc17c4112cfce15b4a74856922f798669
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/tts.c

index d1ad656..79bd34d 100644 (file)
@@ -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;