Add missing FINISH event after streaming in AudioManager 22/220322/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 17 Dec 2019 07:21:04 +0000 (16:21 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 17 Dec 2019 07:21:04 +0000 (16:21 +0900)
Change-Id: I044ad8e2c328ae3abd93e542be07675042825fc5

plugins/wakeup-manager/src/wakeup_audio_manager.cpp

index 201c8a6..b1541a6 100644 (file)
@@ -208,6 +208,7 @@ void CAudioManager::streaming_audio_data_thread_func(long start_time)
        MWR_LOGD("[ENTER]");
 
        unique_lock<mutex> lock(mMutex, defer_lock);
+       bool finish_event_sent = false;
 
        lock.lock();
        auto lead = mAudioData.begin();
@@ -286,11 +287,24 @@ void CAudioManager::streaming_audio_data_thread_func(long start_time)
 
                if (MAS_SPEECH_STREAMING_EVENT_FINISH == speech_data.event) {
                        MWR_LOGI("[INFO] Finish to get and send speech data");
+                       finish_event_sent = true;
                        break;
                }
 
                advance(lead, 1);
        }
+
+       if (true != finish_event_sent) {
+               unsigned char final_buffer[2] = {'\0', };
+               for (const auto& observer : mObservers) {
+                       if (observer) {
+                               if (!observer->on_streaming_audio_data(
+                                       MAS_SPEECH_STREAMING_EVENT_FINISH, final_buffer, sizeof(final_buffer))) {
+                                       LOGE("[Recorder WARNING] One of the observer returned false");
+                               }
+                       }
+               }
+       }
        MWR_LOGD("[EXIT]");
 }