Make sure FINISH event is delivered when streaming
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 20 Sep 2019 10:44:27 +0000 (19:44 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 20 Sep 2019 10:45:43 +0000 (19:45 +0900)
Change-Id: Ib779d5bd6a151fdcf9981c9722b805fe191a4e30

plugins/wakeup-manager/src/wakeup_engine_manager.cpp

index dc75571..db4a4ad 100644 (file)
@@ -193,6 +193,7 @@ void CWakeupEngineManager::streaming_speech_data_thread_func()
 
        wakeup_speech_data speech_data;
        int index = 0;
+       bool finish_event_sent = false;
 
        while (!(mStopStreamingThread.load())) {
                int ret = -1;
@@ -243,12 +244,25 @@ void CWakeupEngineManager::streaming_speech_data_thread_func()
 
                        if (WAKEUP_SPEECH_STREAMING_EVENT_FINISH == speech_data.event) {
                                MWR_LOGI("[INFO] Finish to get and send speech data");
+                               finish_event_sent = true;
                                break;
                        }
 
                        index++;
                }
        }
+
+       if (true != finish_event_sent) {
+               unsigned char final_buffer[2] = {'\0', };
+               for (const auto& observer : mObservers) {
+                       if (observer) {
+                               if (!observer->on_streaming_audio_data(
+                                       WAKEUP_SPEECH_STREAMING_EVENT_FINISH, final_buffer, sizeof(final_buffer))) {
+                                       LOGE("[Recorder WARNING] One of the observer returned false");
+                               }
+                       }
+               }
+       }
 }
 
 void CWakeupEngineManager::start_streaming_current_utterance_data()