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

Unified Diff: content/renderer/media/audio_renderer_mixer_manager.h

Issue 596073002: Allow better AudioRendererMixer reuse by ignoring irrelevant params. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | content/renderer/media/audio_renderer_mixer_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/audio_renderer_mixer_manager.h
diff --git a/content/renderer/media/audio_renderer_mixer_manager.h b/content/renderer/media/audio_renderer_mixer_manager.h
index 0a76b5dc3941b2bd8eb34109cdafe3b5f054b18b..ef3978937a90c4b65ac3a8c02e31602a382cdc13 100644
--- a/content/renderer/media/audio_renderer_mixer_manager.h
+++ b/content/renderer/media/audio_renderer_mixer_manager.h
@@ -71,6 +71,24 @@ class CONTENT_EXPORT AudioRendererMixerManager {
// RenderView and with the same AudioParameters can be mixed together.
typedef std::pair<int, media::AudioParameters> MixerKey;
xhwang 2014/09/23 21:14:04 nit: comment that the "int" is for render view ID.
DaleCurtis 2014/09/23 21:17:45 Done.
+ // Custom compare operator for the AudioRendererMixerMap. Allows reuse of
+ // mixers where irrelevant keys mismatch (i.e., effects, bits per sample).
xhwang 2014/09/23 21:14:04 s/where/where only/
DaleCurtis 2014/09/23 21:17:45 Done.
+ struct MixerKeyCompare {
+ bool operator()(const MixerKey& a, const MixerKey& b) const {
+ if (a.first != b.first)
+ return a.first < b.first;
+ if (a.second.sample_rate() != b.second.sample_rate())
+ return a.second.sample_rate() < b.second.sample_rate();
+ if (a.second.channels() != b.second.channels())
+ return a.second.channels() < b.second.channels();
+
+ // Ignore effects(), bits_per_sample(), format(), and frames_per_buffer(),
+ // these parameters do not affect mixer reuse. All AudioRendererMixer
+ // units disable FIFO, so frames_per_buffer() can be safely ignored.
+ return a.second.channel_layout() < b.second.channel_layout();
+ }
+ };
+
// Map of MixerKey to <AudioRendererMixer, Count>. Count allows
// AudioRendererMixerManager to keep track explicitly (v.s. RefCounted which
// is implicit) of the number of outstanding AudioRendererMixers.
@@ -78,7 +96,8 @@ class CONTENT_EXPORT AudioRendererMixerManager {
media::AudioRendererMixer* mixer;
int ref_count;
};
- typedef std::map<MixerKey, AudioRendererMixerReference> AudioRendererMixerMap;
+ typedef std::map<MixerKey, AudioRendererMixerReference, MixerKeyCompare>
+ AudioRendererMixerMap;
// Overrides the AudioRendererSink implementation for unit testing.
void SetAudioRendererSinkForTesting(media::AudioRendererSink* sink);
« no previous file with comments | « no previous file | content/renderer/media/audio_renderer_mixer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698