Merge "Add more logs for checking wakeup process" into tizen
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 12 Aug 2019 11:55:43 +0000 (11:55 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Mon, 12 Aug 2019 11:55:43 +0000 (11:55 +0000)
plugins/wakeup-manager/inc/wakeup_audio_manager.h
plugins/wakeup-manager/src/wakeup_audio_manager.cpp
plugins/wakeup-manager/src/wakeup_manager.cpp
plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp
src/multi_assistant_service_plugin.c

index 0e1bc6b..d23a1f5 100644 (file)
@@ -66,6 +66,7 @@ public:
 
        void feed_audio_data(wakeup_speech_streaming_event_e event, void* buffer, int len);
        void finalize_audio_data();
+       void clear_audio_data();
 
        void start_streaming_current_utterance_data(long start_time = 0);
        void stop_streaming_current_utterance_data();
index d6c1868..75f21e6 100644 (file)
@@ -271,6 +271,16 @@ void CAudioManager::finalize_audio_data()
        }
 }
 
+void CAudioManager::clear_audio_data()
+{
+       lock_guard<mutex> lock(mMutex);
+
+       for (const auto &data : mAudioData) {
+               if (data.data.buffer) free(data.data.buffer);
+       }
+       mAudioData.clear();
+}
+
 void CAudioManager::notify_audio_data_recording(long time, void* data, int len)
 {
        for (const auto& observer : mObservers) {
@@ -298,7 +308,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 +333,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 ddf1007..bd7205a 100644 (file)
@@ -385,6 +385,8 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len)
                        stop_streaming_utterance_data();
                        stop_streaming_previous_utterance_data();
                        stop_streaming_follow_up_data();
+
+                       mAudioManager.clear_audio_data();
                        change_manager_state(WAKEUP_MANAGER_STATE_UTTERANCE);
 
                        mVoiceKeyPressed = true;
@@ -401,7 +403,7 @@ bool CWakeupManager::process_event(ma_plugin_event_e event, void* data, int len)
                        event_info.wakeup_end_time = get_current_milliseconds_after_epoch();
                        event_info.wakeup_engine = WAKEUP_ENGINE_VOICE_KEY;
 
-                       static string appid = mWakeupSettings.get_default_assistant_appid();
+                       string appid = mWakeupSettings.get_default_assistant_appid();
                        event_info.wakeup_appid = appid.c_str();
                        MWR_LOGD("wakeup_appid : %s", event_info.wakeup_appid);
 
@@ -725,7 +727,9 @@ bool CWakeupManager::CAudioEventObserver::on_recording_audio_data(long time, voi
 
        if (false == engine_manager->get_audio_data_required()) return false;
 
-       engine_manager->engine_feed_audio_data(time, data, len);
+       if (mWakeupManager->get_voice_key_pressed() != true) {
+               engine_manager->engine_feed_audio_data(time, data, len);
+       }
 
        return true;
 }
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 198f549..cd2fa8d 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;