Prevent burst transmission of streaming audio data 96/222496/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 15 Jan 2020 05:51:54 +0000 (14:51 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 15 Jan 2020 12:33:05 +0000 (21:33 +0900)
Change-Id: I02c0086a708cdea0adcbf259a4aa23065c5ebb3b

plugins/wakeup-manager/src/wakeup_engine_manager.cpp

index 41af682..642b0f8 100644 (file)
@@ -363,6 +363,7 @@ void CWakeupEngineManager::streaming_speech_data_thread_func()
                }
        }
 
+       int burst_count = 0;
        while (!(mStopStreamingThread.load())) {
                int ret = -1;
                int cnt = 0;
@@ -376,6 +377,7 @@ void CWakeupEngineManager::streaming_speech_data_thread_func()
 
                                /* waiting */
                                while (!(mStopStreamingThread.load())) {
+                                       burst_count = 0;
                                        this_thread::sleep_for(chrono::milliseconds(10));
                                        if (index < interface->get_utterance_data_count()) {
                                                MWR_LOGD("[INFO] Resume thread");
@@ -428,6 +430,13 @@ void CWakeupEngineManager::streaming_speech_data_thread_func()
                                }
                        }
 #endif
+                       const int sleep_duration_in_millis = 10;
+                       const int max_burst_count = 3;
+                       if (++burst_count >= max_burst_count) {
+                               burst_count = 0;
+                               this_thread::sleep_for(chrono::milliseconds(sleep_duration_in_millis));
+                               MWR_LOGI("[INFO] Streaming data burst transmission detected, forcing sleep");
+                       }
                        for (const auto& observer : mObservers) {
                                if (observer) {
                                        if (!observer->on_streaming_audio_data(