From 8f9401365185e6885b29cb82ffe218cdfcbbb2b7 Mon Sep 17 00:00:00 2001 From: "andrew@webrtc.org" Date: Wed, 11 Sep 2013 22:35:00 +0000 Subject: [PATCH] Reduce frequency of high audio delay warning logs. This will log the warning every 5 seconds instead of every 10 ms. BUG=b/10674993 TESTED=Ran voe_cmd_test with hard-coded high delay. Observed a log every 5 seconds. R=noahric@chromium.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2184009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4729 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_device/audio_device_buffer.cc | 31 ++++++++++++------- .../audio_device/audio_device_buffer.h | 7 +++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/webrtc/modules/audio_device/audio_device_buffer.cc b/webrtc/modules/audio_device/audio_device_buffer.cc index e3ceb5674..e6cde5d74 100644 --- a/webrtc/modules/audio_device/audio_device_buffer.cc +++ b/webrtc/modules/audio_device/audio_device_buffer.cc @@ -12,6 +12,7 @@ #include "webrtc/modules/audio_device/audio_device_config.h" #include "webrtc/modules/audio_device/audio_device_utility.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/trace.h" #include @@ -22,6 +23,9 @@ namespace webrtc { +static const int kHighDelayThresholdMs = 300; +static const int kLogHighDelayIntervalFrames = 500; // 5 seconds. + // ---------------------------------------------------------------------------- // ctor // ---------------------------------------------------------------------------- @@ -49,7 +53,9 @@ AudioDeviceBuffer::AudioDeviceBuffer() : _typingStatus(false), _playDelayMS(0), _recDelayMS(0), - _clockDrift(0) { + _clockDrift(0), + // Set to the interval in order to log on the first occurrence. + high_delay_counter_(kLogHighDelayIntervalFrames) { // valid ID will be set later by SetId, use -1 for now WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s created", __FUNCTION__); memset(_recBuffer, 0, kMaxBufferSizeBytes); @@ -286,18 +292,21 @@ uint32_t AudioDeviceBuffer::NewMicLevel() const // SetVQEData // ---------------------------------------------------------------------------- -int32_t AudioDeviceBuffer::SetVQEData(uint32_t playDelayMS, uint32_t recDelayMS, int32_t clockDrift) -{ - if ((playDelayMS + recDelayMS) > 300) - { - WEBRTC_TRACE(kTraceWarning, kTraceUtility, _id, "too long delay (play:%i rec:%i)", playDelayMS, recDelayMS, clockDrift); +void AudioDeviceBuffer::SetVQEData(uint32_t playDelayMs, uint32_t recDelayMs, + int32_t clockDrift) { + if (high_delay_counter_ < kLogHighDelayIntervalFrames) { + ++high_delay_counter_; + } else { + if (playDelayMs + recDelayMs > kHighDelayThresholdMs) { + high_delay_counter_ = 0; + LOG(LS_WARNING) << "High audio device delay reported (render=" + << playDelayMs << " ms, capture=" << recDelayMs << " ms)"; } + } - _playDelayMS = playDelayMS; - _recDelayMS = recDelayMS; - _clockDrift = clockDrift; - - return 0; + _playDelayMS = playDelayMs; + _recDelayMS = recDelayMs; + _clockDrift = clockDrift; } // ---------------------------------------------------------------------------- diff --git a/webrtc/modules/audio_device/audio_device_buffer.h b/webrtc/modules/audio_device/audio_device_buffer.h index 77aaac7f3..86f4d6d7a 100644 --- a/webrtc/modules/audio_device/audio_device_buffer.h +++ b/webrtc/modules/audio_device/audio_device_buffer.h @@ -54,9 +54,9 @@ public: int32_t SetRecordedBuffer(const void* audioBuffer, uint32_t nSamples); int32_t SetCurrentMicLevel(uint32_t level); - int32_t SetVQEData(uint32_t playDelayMS, - uint32_t recDelayMS, - int32_t clockDrift); + void SetVQEData(uint32_t playDelayMS, + uint32_t recDelayMS, + int32_t clockDrift); int32_t DeliverRecordedData(); uint32_t NewMicLevel() const; @@ -118,6 +118,7 @@ private: uint32_t _recDelayMS; int32_t _clockDrift; + int high_delay_counter_; }; } // namespace webrtc