From 4580217b56791056036e6d38edb07fc0b55d06ae Mon Sep 17 00:00:00 2001 From: henrika Date: Thu, 28 Sep 2017 09:39:34 +0200 Subject: [PATCH] Adds WebRTC.Audio.EncodingTaskQueueLatencyMs Part II of https://webrtc-review.googlesource.com/c/src/+/1584 Bug: webrtc:8206 Change-Id: I71ff164a884c61404d1c542d943dd12a5ee2de6f Reviewed-on: https://webrtc-review.googlesource.com/4180 Commit-Queue: Henrik Andreassson Reviewed-by: Henrik Lundin Cr-Commit-Position: refs/heads/master@{#20012} --- voice_engine/channel.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc index 4dff3de585..e3ba1eeb55 100644 --- a/voice_engine/channel.cc +++ b/voice_engine/channel.cc @@ -38,6 +38,7 @@ #include "rtc_base/thread_checker.h" #include "rtc_base/timeutils.h" #include "system_wrappers/include/field_trial.h" +#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/trace.h" #include "voice_engine/statistics.h" #include "voice_engine/utility.h" @@ -1643,6 +1644,9 @@ void Channel::ProcessAndEncodeAudio(const AudioFrame& audio_input) { // either into pool of frames or into the task itself. audio_frame->CopyFrom(audio_input); audio_frame->id_ = ChannelId(); + // Profile time between when the audio frame is added to the task queue and + // when the task is actually executed. + audio_frame->UpdateProfileTimeStamp(); encoder_queue_->PostTask(std::unique_ptr( new ProcessAndEncodeAudioTask(std::move(audio_frame), this))); } @@ -1682,6 +1686,12 @@ void Channel::ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input) { RTC_DCHECK_LE(audio_input->num_channels_, 2); RTC_DCHECK_EQ(audio_input->id_, ChannelId()); + // Measure time between when the audio frame is added to the task queue and + // when the task is actually executed. Goal is to keep track of unwanted + // extra latency added by the task queue. + RTC_HISTOGRAM_COUNTS_10000("WebRTC.Audio.EncodingTaskQueueLatencyMs", + audio_input->ElapsedProfileTimeMs()); + bool is_muted = InputMute(); AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted);