Add managing prepare thread 13/198213/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Wed, 16 Jan 2019 11:57:27 +0000 (20:57 +0900)
committerSooyeon Kim <sooyeon.kim@samsung.com>
Tue, 22 Jan 2019 09:40:41 +0000 (09:40 +0000)
Change-Id: Ibc4aacb3b0982c5c15b1f18f3f22b39ddcda64ff
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
(cherry picked from commit f582749f23e386815bd15d2c51e16de0c286364e)

client/vc_mgr.c

index 1d0974fffc395c6a7ee6a60e121efe94522ef524..b65a48f7a8ea84cda03a9e7428952fd518e4bed7 100644 (file)
@@ -71,6 +71,8 @@ static vc_audio_channel_e g_feedback_audio_channel = 0;
 static vc_audio_type_e g_feedback_audio_type = 0;
 static Ecore_Thread* g_feedback_thread = NULL;
 
+static Ecore_Thread* g_mgr_thread = NULL;
+
 static Eina_Bool __vc_mgr_notify_state_changed(void *data);
 static void __vc_mgr_notify_error(void *data);
 static Eina_Bool __vc_mgr_notify_result(void *data);
@@ -530,6 +532,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread)
 static void __end_prepare_thread(void *data, Ecore_Thread *thread)
 {
        SLOG(LOG_INFO, TAG_VCM, "@@@ End prepare thread");
+       g_mgr_thread = NULL;
 }
 
 int vc_mgr_prepare(void)
@@ -559,9 +562,13 @@ int vc_mgr_prepare(void)
                return VC_ERROR_INVALID_STATE;
        }
 
-       ecore_thread_main_loop_begin();
-       ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL);
-       ecore_thread_main_loop_end();
+       bool is_exist = ecore_thread_check(g_mgr_thread);
+       if (NULL == g_mgr_thread || TRUE == is_exist) {
+               SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Create a new thread for preparation");
+               ecore_thread_main_loop_begin();
+               g_mgr_thread = ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL);
+               ecore_thread_main_loop_end();
+       }
 
        SLOG(LOG_DEBUG, TAG_VCM, "@@@");
 
@@ -4210,8 +4217,8 @@ int vc_mgr_start_feedback(void)
        }
 
 #if 1
-       bool is_canceled = ecore_thread_check(g_feedback_thread);
-       if (NULL == g_feedback_thread || TRUE == is_canceled) {
+       bool is_exist = ecore_thread_check(g_feedback_thread);
+       if (NULL == g_feedback_thread || TRUE == is_exist) {
                SLOG(LOG_INFO, TAG_VCM, "[INFO] ecore thread run : __tts_feedback_thread");
                g_feedback_thread = ecore_thread_run(__tts_feedback_thread, __end_tts_feedback_thread, NULL, NULL);
        }