From 9202b75bdccb9fa9138c895ab5a75de7cd5426ec Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 9 Aug 2019 15:11:21 +0900 Subject: [PATCH] Fix thread deadlock issue Change-Id: I810183593fc05fe93300dec9f686d6088a8006a6 --- plugins/wakeup-manager/src/wakeup_audio_manager.cpp | 12 ++++++++++-- .../wakeup-manager/src/wakeup_manager_wrapper.cpp | 2 +- src/multi_assistant_service_plugin.c | 10 +++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/plugins/wakeup-manager/src/wakeup_audio_manager.cpp b/plugins/wakeup-manager/src/wakeup_audio_manager.cpp index d6c1868..60f2020 100644 --- a/plugins/wakeup-manager/src/wakeup_audio_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_audio_manager.cpp @@ -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); } diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index 1dc8a06..5da291c 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -481,4 +481,4 @@ void CWakeupEventObserver::on_streaming_audio_data( } else { MWR_LOGI("[INFO] No service streaming callback"); } -} \ No newline at end of file +} diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index 1669d34..5f9c8f1 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -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; -- 2.34.1