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

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

Issue 10636036: Enable renderer side mixing behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Created 8 years, 5 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: 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
new file mode 100644
index 0000000000000000000000000000000000000000..d000f32e4d50d8733adb2018cf3b9227d2cabaa6
--- /dev/null
+++ b/content/renderer/media/audio_renderer_mixer_manager.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
+#define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
+
+#include <map>
+
+#include "base/synchronization/lock.h"
+#include "content/common/content_export.h"
+#include "media/audio/audio_parameters.h"
+
+namespace media {
+class AudioRendererMixer;
+class AudioRendererMixerInput;
+}
+
+namespace content {
+
+// Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based
+// on their AudioParameters configuration. Inputs with the same AudioParameters
+// configuration will share a mixer while a new AudioRendererMixer will be
+// lazily created if one with the exact AudioParameters does not exist.
+//
+// There should only be one instance of AudioRendererMixerManager per render
+// thread.
+//
+// TODO(dalecurtis): Right now we require AudioParameters to be an exact match
+// when we should be able to ignore bits per channel since we're only dealing
+// with floats. However, bits per channel is currently used to interleave the
+// audio data by AudioDevice::AudioThreadCallback::Process for consumption via
+// the shared memory. See http://crbug.com/114700.
+class CONTENT_EXPORT AudioRendererMixerManager {
+ public:
+ AudioRendererMixerManager();
+ ~AudioRendererMixerManager();
+
+ // Creates an AudioRendererMixerInput with the proper callbacks necessary to
+ // retrieve an AudioRendererMixer instance from AudioRendererMixerManager.
+ // Caller must ensure AudioRendererMixerManager outlives the returned input.
+ media::AudioRendererMixerInput* CreateInput();
+
+ private:
+ friend class AudioRendererMixerManagerTest;
+
+ // Returns a mixer instance based on AudioParameters; an existing one if one
+ // with the provided AudioParameters exists or a new one if not.
+ media::AudioRendererMixer* GetMixer(const media::AudioParameters& params);
+
+ // Remove a mixer instance given a mixer if the only other reference is held
+ // by AudioRendererMixerManager. Every AudioRendererMixer owner must call
+ // this method when it's done with a mixer.
+ void RemoveMixer(const media::AudioParameters& params);
+
+ // Map of AudioParameters to <AudioRendererMixer, Count>. Count allows
+ // AudioRendererMixerManager to keep track explicitly (v.s. RefCounted which
+ // is implicit) of the number of outstanding AudioRendererMixers.
+ struct AudioRendererMixerReference {
+ media::AudioRendererMixer* mixer;
+ int ref_count;
+ };
+ typedef std::map<media::AudioParameters, AudioRendererMixerReference,
+ media::AudioParameters::Compare> AudioRendererMixerMap;
+ AudioRendererMixerMap mixer_map_;
scherkus (not reviewing) 2012/07/13 23:17:38 nit: don't bother with _map / _list to variable na
DaleCurtis 2012/07/14 00:39:26 Done.
+ base::Lock mixer_map_lock_;
scherkus (not reviewing) 2012/07/13 23:17:38 ditto here with mixers_lock_
DaleCurtis 2012/07/14 00:39:26 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698