Change to thread instance of client 73/239373/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 08:26:24 +0000 (17:26 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Fri, 24 Jul 2020 08:26:24 +0000 (17:26 +0900)
Change-Id: I502ce4bd931400694f5afbf20c41b77f8983ac4f
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/tts.c
client/tts_client.h

index 79bd34d..ef68325 100644 (file)
@@ -63,6 +63,8 @@ static Eina_Bool __tts_notify_state_changed(void *data);
 static Eina_Bool __tts_notify_error(void *data);
 int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg);
 int __tts_recheck_screen_reader();
+static void __start_reprepare_thread(void* data, Ecore_Thread* thread);
+static void __end_reprepare_thread(void* data, Ecore_Thread* thread);
 
 static const char* tts_tag()
 {
@@ -894,8 +896,10 @@ static Eina_Bool __tts_connect_daemon(void *data)
                /* 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");
-
+                       if (NULL == client->thread) {
+                               SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: start_reprepare_thread");
+                               client->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, tts);
+                       }
                        return EINA_FALSE;
                }
        }
@@ -1102,7 +1106,10 @@ static Eina_Bool __send_hello(void *data)
                /* 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");
+                       if (NULL == client->thread) {
+                               SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: start_reprepare_thread");
+                               client->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, tts);
+                       }
                        client->hello_timer = NULL;
                        return EINA_FALSE;
                }
@@ -1133,6 +1140,7 @@ static Eina_Bool __send_hello(void *data)
                client->hello_timer = ecore_timer_add(0.5, __send_hello, tts);
                return EINA_FALSE;
        }
+
        return EINA_TRUE;
 }
 
@@ -2564,6 +2572,15 @@ static void __start_reprepare_thread(void* data, Ecore_Thread* thread)
 static void __end_reprepare_thread(void* data, Ecore_Thread* thread)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[INFO] end reprepare thread");
+
+       tts_h tts = (tts_h)data;
+       tts_client_s* client = tts_client_get(tts);
+       /* check handle */
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is null");
+               return;
+       }
+       client->thread = NULL;
 }
 
 int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg)
@@ -2608,7 +2625,10 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg)
 
                                        data->current_state = TTS_STATE_CREATED;
                                        data->reason = 0;
-                                       ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, data);
+                                       if (NULL == data->thread) {
+                                               SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: start_reprepare_thread");
+                                               data->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, data->tts);
+                                       }
                                }
 
                                /* Next item */
@@ -2646,7 +2666,10 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg)
 
                        client->current_state = TTS_STATE_CREATED;
                        client->reason = 0;
-                       ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, client);
+                       if (NULL == client->thread) {
+                               SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: start_reprepare_thread");
+                               client->thread = ecore_thread_run(__start_reprepare_thread, __end_reprepare_thread, NULL, client->tts);
+                       }
                }
        }
 
index ce6989c..f913877 100644 (file)
@@ -72,6 +72,9 @@ typedef struct {
 
        /* repetition */
        char*           text_repeat;
+
+       /* thread */
+       Ecore_Thread* thread;
 } tts_client_s;
 
 int tts_client_new(tts_h* tts);