Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Unified Diff: webrtc/modules/audio_device/audio_device_buffer.cc

Issue 2190343002: Adds delta-time logging for audio playout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/audio_device_buffer.cc
diff --git a/webrtc/modules/audio_device/audio_device_buffer.cc b/webrtc/modules/audio_device/audio_device_buffer.cc
index b40d5afeb879717b100e6bd56ffb3f62336420a6..f31dd7cc759e7ea30382399e78ae27426062b039 100644
--- a/webrtc/modules/audio_device/audio_device_buffer.cc
+++ b/webrtc/modules/audio_device/audio_device_buffer.cc
@@ -72,6 +72,23 @@ AudioDeviceBuffer::AudioDeviceBuffer()
AudioDeviceBuffer::~AudioDeviceBuffer() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
LOG(INFO) << "AudioDeviceBuffer::~dtor";
+
+ int total_diff_time = 0;
+ int num_measurements = 0;
+ while (!playout_diff_time_map_.empty()) {
magjed_webrtc 2016/07/29 10:07:11 Use a range-based loop instead: for (const auto& k
henrika_webrtc 2016/07/29 11:11:00 Thanks.
+ int time_diff = playout_diff_time_map_.begin()->first;
+ int num_elements = playout_diff_time_map_.begin()->second;
+ total_diff_time += num_elements * time_diff;
+ num_measurements += num_elements;
+ LOG(INFO) << time_diff << " => " << num_elements;
+ playout_diff_time_map_.erase(playout_diff_time_map_.begin());
+ }
+ LOG(INFO) << "total_diff_time: " << total_diff_time;
+ LOG(INFO) << "num_measurements: " << num_measurements;
+ LOG(INFO) << "average: "
+ << static_cast<float>(total_diff_time) / num_measurements;
+
+
_recFile.Flush();
_recFile.CloseFile();
delete &_recFile;
@@ -92,6 +109,7 @@ int32_t AudioDeviceBuffer::RegisterAudioCallback(
int32_t AudioDeviceBuffer::InitPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
LOG(INFO) << __FUNCTION__;
+ last_playout_time_ = rtc::TimeMillis();
if (!timer_has_started_) {
StartTimer();
timer_has_started_ = true;
@@ -333,6 +351,16 @@ int32_t AudioDeviceBuffer::RequestPlayoutData(size_t nSamples) {
size_t playBytesPerSample = 0;
size_t playChannels = 0;
+ // Measure time since last function call and update a map where the key value
+ // corresponds to time differences (in milliseconds), and the mapped element
+ // represents the number of times a given time difference was found.
+ // Writing to map can be done without a lock since it is only read once at
+ // destruction when no audio is running.
+ int64_t now_time = rtc::TimeMillis();
+ int64_t diff_time = rtc::TimeDiff(now_time, last_playout_time_);
magjed_webrtc 2016/07/29 10:07:11 Consider using diff_time = std::min(1000, diff_tim
henrika_webrtc 2016/07/29 11:11:00 Will add the cap, thanks! Would like to keep the
magjed_webrtc 2016/07/29 12:16:07 The map has a big overhead per element and will ne
henrika_webrtc 2016/07/29 12:50:24 Will change
+ last_playout_time_ = now_time;
+ playout_diff_time_map_[diff_time]++;
+
// TOOD(henrika): improve bad locking model and make it more clear that only
// 10ms buffer sizes is supported in WebRTC.
{

Powered by Google App Engine
This is Rietveld 408576698