return end(v) != find(begin(v), end(v), x);
}
+static long long get_current_milliseconds_after_epoch()
+{
+ auto now = chrono::steady_clock::now();
+ auto now_ms = chrono::time_point_cast<chrono::milliseconds>(now);
+ /* number of milliseconds since the epoch of system_clock */
+ auto value = now_ms.time_since_epoch();
+
+ return value.count();
+}
+
CWakeupEngineManager::CWakeupEngineManager()
{
}
/* get feedback data */
if (interface && interface->get_utterance_data) {
ret = interface->get_utterance_data(index, &speech_data);
+ mStreamingHistory.last_audio_fetched.store(get_current_milliseconds_after_epoch());
+
if (0 != ret) {
/* empty queue */
MWR_LOGD("[DEBUG] No feedback data. Waiting mode : %d", ret);
MWR_LOGD("[INFO] Resume thread");
break;
}
+ mStreamingHistory.last_count_fetched.store(get_current_milliseconds_after_epoch());
if (g_speech_pcm_wait_count < cnt) {
unsigned char final_buffer[2] = {'\0', };
MWR_LOGE("[ERROR] Wrong request, there's no pcm data");
MAS_SPEECH_STREAMING_EVENT_FINISH, final_buffer, sizeof(final_buffer))) {
LOGE("[Recorder WARNING] One of the observer returned false");
}
+ mStreamingHistory.last_audio_sent.store(get_current_milliseconds_after_epoch());
}
}
return;
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");
+ this_thread::sleep_for(chrono::milliseconds(sleep_duration_in_millis));
}
for (const auto& observer : mObservers) {
if (observer) {
speech_data.event, speech_data.buffer, speech_data.len)) {
LOGE("[Recorder WARNING] One of the observer returned false");
}
+ mStreamingHistory.last_audio_sent.store(get_current_milliseconds_after_epoch());
}
}
index++;
}
}
+ MWR_LOGE("[INFO] Streaming loop exit");
if (true != finish_event_sent) {
unsigned char final_buffer[2] = {'\0', };
MAS_SPEECH_STREAMING_EVENT_FINISH, final_buffer, sizeof(final_buffer))) {
LOGE("[Recorder WARNING] One of the observer returned false");
}
+ mStreamingHistory.last_audio_sent.store(get_current_milliseconds_after_epoch());
}
}
#ifdef BUF_SAVE_MODE
{
MWR_LOGI("[ENTER]");
if (mStreamingThread.joinable()) {
- MWR_LOGD("mStreamingThread is joinable, trying join()");
+ MWR_LOGE("mStreamingThread is joinable, trying join() %lld %lld %lld %lld",
+ get_current_milliseconds_after_epoch(),
+ mStreamingHistory.last_audio_fetched.load(),
+ mStreamingHistory.last_count_fetched.load(),
+ mStreamingHistory.last_audio_sent.load());
mStopStreamingThread.store(true);
mStreamingThread.join();
}