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
diff --git a/webrtc/modules/audio_device/audio_device_buffer.cc b/webrtc/modules/audio_device/audio_device_buffer.cc
index e3ceb56..e6cde5d 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 <assert.h>
@@ -22,6 +23,9 @@
namespace webrtc {
+static const int kHighDelayThresholdMs = 300;
+static const int kLogHighDelayIntervalFrames = 500; // 5 seconds.
+
// ----------------------------------------------------------------------------
// ctor
// ----------------------------------------------------------------------------
@@ -49,7 +53,9 @@
_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 @@
// 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;
}
// ----------------------------------------------------------------------------