| Index: media/base/audio_renderer_mixer.cc
|
| diff --git a/media/base/audio_renderer_mixer.cc b/media/base/audio_renderer_mixer.cc
|
| index 008fcce793320af352ff80ab17ff51c8ea17cff3..83539692048f1c7faafdcd596860e5a393489b14 100644
|
| --- a/media/base/audio_renderer_mixer.cc
|
| +++ b/media/base/audio_renderer_mixer.cc
|
| @@ -10,20 +10,52 @@
|
| #include "base/bind_helpers.h"
|
| #include "base/logging.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/metrics/histogram_macros.h"
|
|
|
| namespace media {
|
|
|
| enum { kPauseDelaySeconds = 10 };
|
|
|
| +// Tracks the maximum value of a counter and logs it into a UMA histogram upon
|
| +// the destruciton.
|
| +class AudioRendererMixer::UMAMaxValueTracker {
|
| + public:
|
| + UMAMaxValueTracker(const std::string& histogram_name)
|
| + : histogram_name_(histogram_name), count_(0), max_count_(0) {}
|
| +
|
| + ~UMAMaxValueTracker() {
|
| + if (max_count_ && !histogram_name_.empty())
|
| + LOCAL_HISTOGRAM_CUSTOM_COUNTS(histogram_name_, max_count_, 1, 100, 100);
|
| + }
|
| +
|
| + // Increments the counter, updates the maximum.
|
| + void Increment() {
|
| + ++count_;
|
| + if (max_count_ < count_)
|
| + max_count_ = count_;
|
| + }
|
| +
|
| + // Decrements the counter.
|
| + void Decrement() { --count_; }
|
| +
|
| + private:
|
| + const std::string histogram_name_;
|
| + int count_;
|
| + int max_count_;
|
| + DISALLOW_COPY_AND_ASSIGN(UMAMaxValueTracker);
|
| +};
|
| +
|
| AudioRendererMixer::AudioRendererMixer(const AudioParameters& output_params,
|
| - scoped_refptr<AudioRendererSink> sink)
|
| + scoped_refptr<AudioRendererSink> sink,
|
| + const std::string& histogram_name)
|
| : output_params_(output_params),
|
| audio_sink_(std::move(sink)),
|
| master_converter_(output_params, output_params, true),
|
| pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)),
|
| last_play_time_(base::TimeTicks::Now()),
|
| // Initialize |playing_| to true since Start() results in an auto-play.
|
| - playing_(true) {
|
| + playing_(true),
|
| + input_count_tracker_(new UMAMaxValueTracker(histogram_name)) {
|
| DCHECK(audio_sink_);
|
| audio_sink_->Initialize(output_params, this);
|
| audio_sink_->Start();
|
| @@ -70,6 +102,8 @@ void AudioRendererMixer::AddMixerInput(const AudioParameters& input_params,
|
| }
|
| converter->second->AddInput(input);
|
| }
|
| +
|
| + input_count_tracker_->Increment();
|
| }
|
|
|
| void AudioRendererMixer::RemoveMixerInput(
|
| @@ -91,6 +125,8 @@ void AudioRendererMixer::RemoveMixerInput(
|
| converters_.erase(converter);
|
| }
|
| }
|
| +
|
| + input_count_tracker_->Decrement();
|
| }
|
|
|
| void AudioRendererMixer::AddErrorCallback(const base::Closure& error_cb) {
|
|
|