Fix thread deadlock issue
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 9 Aug 2019 06:11:21 +0000 (15:11 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 9 Aug 2019 09:15:36 +0000 (18:15 +0900)
Change-Id: I810183593fc05fe93300dec9f686d6088a8006a6

plugins/wakeup-manager/src/wakeup_audio_manager.cpp
plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp
src/multi_assistant_service_plugin.c

index d6c1868..60f2020 100644 (file)
@@ -298,7 +298,11 @@ void CAudioManager::stop_streaming_current_utterance_data()
        if (mStreamingThread.joinable()) {
                MWR_LOGD("mStreamingThread is joinable, trying join()");
                mStopStreamingThread.store(true);
-               mStreamingThread.join();
+               try {
+                       mStreamingThread.join();
+               } catch (std::exception &e) {
+                       MWR_LOGE("Exception thrown : %s", e.what());
+               }
        }
        mStopStreamingThread.store(false);
 
@@ -319,7 +323,11 @@ void CAudioManager::stop_streaming_previous_utterance_data()
        if (mStreamingPreviousThread.joinable()) {
                MWR_LOGD("mStreamingPreviousThread is joinable, trying join()");
                mStopStreamingPreviousThread.store(true);
-               mStreamingPreviousThread.join();
+               try {
+                       mStreamingPreviousThread.join();
+               } catch (std::exception &e) {
+                       MWR_LOGE("Exception thrown : %s", e.what());
+               }
        }
        mStopStreamingThread.store(false);
 }
index 1dc8a06..5da291c 100644 (file)
@@ -481,4 +481,4 @@ void CWakeupEventObserver::on_streaming_audio_data(
        } else {
                MWR_LOGI("[INFO] No service streaming callback");
        }
-}
\ No newline at end of file
+}
index 1669d34..5f9c8f1 100644 (file)
@@ -268,10 +268,18 @@ static bool __validate_streaming_event_order(int pid, wakeup_speech_streaming_ev
        return ret;
 }
 
+static Eina_Bool handle_speech_streaming_event_failure(void *data)
+{
+       mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
+    return ECORE_CALLBACK_CANCEL;
+}
+
 static void __audio_streaming_cb(wakeup_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data)
 {
        if (event == WAKEUP_SPEECH_STREAMING_EVENT_FAIL) {
-               mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR);
+               ecore_thread_main_loop_begin();
+               ecore_timer_add(0.0f, handle_speech_streaming_event_failure, NULL);
+               ecore_thread_main_loop_begin();
                return;
        }
        static int count = 0;