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

Unified Diff: media/base/audio_renderer_mixer.cc

Issue 2067863003: Mixing audio with different latency requirements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing bot redness Created 4 years, 6 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: media/base/audio_renderer_mixer.cc
diff --git a/media/base/audio_renderer_mixer.cc b/media/base/audio_renderer_mixer.cc
index 008fcce793320af352ff80ab17ff51c8ea17cff3..51f9c3e73846278ac2fe7dde992f3c9af730986e 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
+// each increase of the maximum. NOT thread-safe, make sure it is used under
+// lock.
+class AudioRendererMixer::UMAMaxValueTracker {
+ public:
+ UMAMaxValueTracker(const UmaLogCallback& log_callback)
+ : log_callback_(log_callback), count_(0), max_count_(0) {}
+
+ ~UMAMaxValueTracker() {}
+
+ // Increments the counter, updates the maximum.
+ void Increment() {
+ ++count_;
+ if (max_count_ < count_) {
+ max_count_ = count_;
+ log_callback_.Run(max_count_);
+ }
+ }
+
+ // Decrements the counter.
+ void Decrement() { --count_; }
+
+ private:
+ const UmaLogCallback log_callback_;
+ 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 UmaLogCallback& log_callback)
: 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(log_callback)) {
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) {
@@ -122,6 +158,11 @@ bool AudioRendererMixer::CurrentThreadIsRenderingThread() {
return audio_sink_->CurrentThreadIsRenderingThread();
}
+void AudioRendererMixer::LogLifetimeUmaStats() {
+ base::AutoLock auto_lock(lock_);
+ input_count_tracker_.reset();
+};
tommi (sloooow) - chröme 2016/06/29 12:26:52 nit: remove ;
o1ka 2016/06/29 13:57:32 removed the method (not used).
+
int AudioRendererMixer::Render(AudioBus* audio_bus,
uint32_t frames_delayed,
uint32_t frames_skipped) {

Powered by Google App Engine
This is Rietveld 408576698