Adds logging of native audio levels and UMA stats to track issues.
This changes added a simple measurement of levels "close to the audio hardware"
both for playout and for recording. These levels are logged once each 10 seconds.
It also adds WebRTC.Audio.RecordedOnlyZeros UMA stat and it is updated at
destuction. It will report true iff all reported recording leves are zero.
BUG=NONE
R=peah@webrtc.org
Review URL: https://codereview.webrtc.org/2328433003 .
Cr-Commit-Position: refs/heads/master@{#14160}
diff --git a/webrtc/modules/audio_device/audio_device_buffer.h b/webrtc/modules/audio_device/audio_device_buffer.h
index e384a31..5c4a063 100644
--- a/webrtc/modules/audio_device/audio_device_buffer.h
+++ b/webrtc/modules/audio_device/audio_device_buffer.h
@@ -86,11 +86,15 @@
// Called periodically on the internal thread created by the TaskQueue.
void LogStats();
+ // Clears all members tracking stats for recording and playout.
+ void ResetRecStats();
+ void ResetPlayStats();
+
// Updates counters in each play/record callback but does it on the task
// queue to ensure that they can be read by LogStats() without any locks since
// each task is serialized by the task queue.
- void UpdateRecStats(size_t num_samples);
- void UpdatePlayStats(size_t num_samples);
+ void UpdateRecStats(const void* audio_buffer, size_t num_samples);
+ void UpdatePlayStats(const void* audio_buffer, size_t num_samples);
// Ensures that methods are called on the same thread as the thread that
// creates this object.
@@ -199,6 +203,23 @@
// Writing to the array is done without a lock since it is only read once at
// destruction when no audio is running.
uint32_t playout_diff_times_[kMaxDeltaTimeInMs + 1] = {0};
+
+ // Contains max level (max(abs(x))) of recorded audio packets over the last
+ // 10 seconds where a new measurement is done twice per second. The level
+ // is reset to zero at each call to LogStats(). Only modified on the task
+ // queue thread.
+ int16_t max_rec_level_;
+
+ // Contains max level of recorded audio packets over the last 10 seconds
+ // where a new measurement is done twice per second.
+ int16_t max_play_level_;
+
+ // Counts number of times we detect "no audio" corresponding to a case where
+ // all level measurements since the last log has been exactly zero.
+ // In other words: this counter is incremented only if 20 measurements
+ // (two per second) in a row equals zero. The member is only incremented on
+ // the task queue and max once every 10th second.
+ size_t num_rec_level_is_zero_;
};
} // namespace webrtc