Stop feedback thread only when stop is requested 60/283960/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 7 Nov 2022 10:55:23 +0000 (19:55 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 28 Dec 2022 06:51:45 +0000 (06:51 +0000)
- Issue:
Sometimes, the feedback thread plays the TTS feedback data for previous
request.

- Solution:
The issue is because feedback thread is exited before the engine
finishing to send TTS feedback data. Thus, some data can be remained in
feedback data queue even if thread is terminated.
This patch fixes termination logic for TTS feedback thread. Through this
patch, TTS feedback thread is terminated only when stop is requested,
and TTS feedback thread tries to consume all feedback data.

Change-Id: I8deaaab5f6b3e44e86b62d1ec3d8735e30a54780
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/vc_mgr.c

index 30c3c2a..0de3b92 100644 (file)
@@ -3409,7 +3409,13 @@ static void __tts_feedback_thread(void* data, Ecore_Thread* thread)
 
                        /* waiting */
                        while (1) {
+                               if (ecore_thread_check(thread) == EINA_TRUE) {
+                                       SLOG(LOG_INFO, TAG_VCM, "[INFO] Stop feedback is called");
+                                       return;
+                               }
+
                                usleep(10000);
+
                                if (0 < vc_mgr_data_get_feedback_data_size()) {
                                        SLOG(LOG_INFO, TAG_VCM, "[INFO] Resume thread");
                                        break;
@@ -3449,16 +3455,6 @@ static void __tts_feedback_thread(void* data, Ecore_Thread* thread)
                                vc_mgr_client_not_use_callback();
 
                                pthread_mutex_unlock(&g_feedback_streaming_cb_mutex);
-
-                               /* If no feedback data and EVENT_FINISH */
-                               if (0 >= vc_mgr_data_get_feedback_data_size() && VC_FEEDBACK_EVENT_FINISH == feedback_data->event) {
-                                       SLOG(LOG_INFO, TAG_VCM, "[INFO] Finish feedback");
-                                       if (feedback_data) {
-                                               free(feedback_data);
-                                               feedback_data = NULL;
-                                       }
-                                       break;
-                               }
                        } else {
                                vc_mgr_vc_tts_streaming_cb callback = NULL;
                                void* user_data = NULL;
@@ -3479,16 +3475,6 @@ static void __tts_feedback_thread(void* data, Ecore_Thread* thread)
                                vc_mgr_client_not_use_callback();
 
                                pthread_mutex_unlock(&g_vc_tts_streaming_cb_mutex);
-
-                               /* If no feedback data and EVENT_FINISH */
-                               if (0 >= vc_mgr_data_get_feedback_data_size() && VC_FEEDBACK_EVENT_FINISH == feedback_data->event) {
-                                       SLOG(LOG_INFO, TAG_VCM, "[INFO] Finish vc tts feedback");
-                                       if (feedback_data) {
-                                               free(feedback_data);
-                                               feedback_data = NULL;
-                                       }
-                                       break;
-                               }
                        }
                        free(feedback_data);
                        feedback_data = NULL;
@@ -3560,8 +3546,12 @@ int vc_mgr_stop_feedback(void)
        RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state);
 
 #if 1
-       ret = -1;
+       if (g_feedback_thread) {
+               ecore_thread_cancel(g_feedback_thread);
+               g_feedback_thread = NULL;
+       }
 
+       ret = -1;
        while (1) {
                vc_feedback_data_s* feedback_data = NULL;