Add a timer for prepare once 39/243739/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Fri, 4 Sep 2020 10:03:54 +0000 (19:03 +0900)
committerSooyeon Kim <sooyeon.kim@samsung.com>
Wed, 9 Sep 2020 12:05:22 +0000 (12:05 +0000)
Change-Id: I747f8e4e14ef5142c71d12242963e9defa29862c
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
(cherry picked from commit b703adec8bf5e1d104c312eb33d1c07f49f7ed73)

client/tts.c

index b1fabc3..5c3d283 100644 (file)
@@ -41,6 +41,7 @@ static int g_max_text_size = -1;
 
 static Ecore_Timer* g_check_state_timer = NULL;
 static Ecore_Timer* g_notify_error_timer = NULL;
+static Ecore_Timer* g_prepare_timer = NULL;
 
 /* for repetition */
 static char* g_language = NULL;
@@ -695,6 +696,12 @@ int tts_destroy(tts_h tts)
                ecore_timer_del(g_notify_error_timer);
                g_notify_error_timer = NULL;
        }
+       /* Delete prepare timer before destroying handle */
+       if (NULL != g_prepare_timer) {
+               ecore_timer_del(g_prepare_timer);
+               g_prepare_timer = NULL;
+       }
+
 
        tts = NULL;
 
@@ -1168,6 +1175,7 @@ static Eina_Bool __send_hello(void *data)
        /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               g_prepare_timer = NULL;
                return EINA_FALSE;
        }
 
@@ -1176,6 +1184,7 @@ static Eina_Bool __send_hello(void *data)
                SLOG(LOG_ERROR, TAG_TTSC, "[INFO] TTS client has been already connected to tts service"); //LCOV_EXCL_LINE
                SLOG(LOG_ERROR, TAG_TTSC, "@@@");
                client->hello_timer = NULL;
+               g_prepare_timer = NULL;
                return EINA_FALSE;
        }
 
@@ -1193,6 +1202,7 @@ static Eina_Bool __send_hello(void *data)
                                client->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, __cancel_reprepare_thread, tts);
                        }
                        client->hello_timer = NULL;
+                       g_prepare_timer = NULL;
                        return EINA_FALSE;
                }
        }
@@ -1210,6 +1220,7 @@ static Eina_Bool __send_hello(void *data)
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Stop to send hello, retry count reaches the limit");
                g_retry_cnt = 0;
                client->hello_timer = NULL;
+               g_prepare_timer = NULL;
 
                is_launched = __is_engine_launched(g_engine_appid);
                SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts engine is launched(%d)", is_launched);
@@ -1220,6 +1231,8 @@ static Eina_Bool __send_hello(void *data)
        if (!client->hello_timer) {
                SLOG(LOG_ERROR, TAG_TTSC, "@@@ Call checking Hello timer callback");
                client->hello_timer = ecore_timer_add(0.5, __send_hello, tts);
+               g_prepare_timer = NULL;
+
                return EINA_FALSE;
        }
 
@@ -1256,7 +1269,11 @@ int tts_prepare(tts_h tts)
                SLOG(LOG_ERROR, TAG_TTSC, "@@@ Call checking Hello timer callback");
                g_retry_cnt = 0;
                ecore_thread_main_loop_begin();
-               ecore_timer_add(0.0, __send_hello, (void*)tts);
+               if (NULL != g_prepare_timer) {
+                       ecore_timer_del(g_prepare_timer);
+                       g_prepare_timer = NULL;
+               }
+               g_prepare_timer = ecore_timer_add(0.0, __send_hello, (void*)tts);
                ecore_thread_main_loop_end();
        }