Commit f3a8a056 authored by henrika's avatar henrika Committed by Commit bot

Adding Media.InputStreamDuration to UMA histograms for low-latency input audio streams.

My idea was that the histogram could show if we do a very large number of short
calls and how the length of the streams are related to the length of
AudioTracks. If so, we might have issues in WebRTC clients or in how we
create/destroy the input streams.

BUG=405449
TEST=Manual testing using WebRTC clients.

Review URL: https://codereview.chromium.org/537573002

Cr-Commit-Position: refs/heads/master@{#293496}
parent ecb23485
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "media/audio/audio_input_controller.h" #include "media/audio/audio_input_controller.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -263,6 +264,7 @@ void AudioInputController::DoCreateForLowLatency(AudioManager* audio_manager, ...@@ -263,6 +264,7 @@ void AudioInputController::DoCreateForLowLatency(AudioManager* audio_manager,
log_silence_state_ = true; log_silence_state_ = true;
#endif #endif
low_latency_create_time_ = base::TimeTicks::Now();
DoCreate(audio_manager, params, device_id); DoCreate(audio_manager, params, device_id);
} }
...@@ -347,8 +349,20 @@ void AudioInputController::DoClose() { ...@@ -347,8 +349,20 @@ void AudioInputController::DoClose() {
if (state_ == CLOSED) if (state_ == CLOSED)
return; return;
if (handler_) // If this is a low-latency stream, log the total duration (since DoCreate)
handler_->OnLog(this, "AIC::DoClose"); // and add it to a UMA histogram.
if (!low_latency_create_time_.is_null()) {
base::TimeDelta duration =
base::TimeTicks::Now() - low_latency_create_time_;
UMA_HISTOGRAM_LONG_TIMES("Media.InputStreamDuration", duration);
if (handler_) {
std::string log_string =
base::StringPrintf("AIC::DoClose: stream duration=");
log_string += base::Int64ToString(duration.InSeconds());
log_string += " seconds";
handler_->OnLog(this, log_string);
}
}
// Delete the timer on the same thread that created it. // Delete the timer on the same thread that created it.
no_data_timer_.reset(); no_data_timer_.reset();
......
...@@ -369,6 +369,9 @@ class MEDIA_EXPORT AudioInputController ...@@ -369,6 +369,9 @@ class MEDIA_EXPORT AudioInputController
size_t prev_key_down_count_; size_t prev_key_down_count_;
// Time when a low-latency stream is created.
base::TimeTicks low_latency_create_time_;
DISALLOW_COPY_AND_ASSIGN(AudioInputController); DISALLOW_COPY_AND_ASSIGN(AudioInputController);
}; };
......
...@@ -11460,6 +11460,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -11460,6 +11460,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="Media.InputStreamDuration" units="ms">
<owner>henrika@chromium.org</owner>
<summary>
Duration in milliseconds of low-latency audio input streams. Sampled when
the stream is closed by the AudioInputController.
</summary>
</histogram>
<histogram name="Media.LinuxAudioIO" enum="LinuxAudioIO"> <histogram name="Media.LinuxAudioIO" enum="LinuxAudioIO">
<owner>dalecurtis@chromium.org</owner> <owner>dalecurtis@chromium.org</owner>
<summary> <summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment