Chromium Code Reviews| 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..dad604747da11a919da9ecd4b88b396251bf2026 |
| --- /dev/null |
| +++ b/content/renderer/media/audio_renderer_mixer_manager.h |
| @@ -0,0 +1,66 @@ |
| +// 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. |
| +// |
| +// Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based |
|
scherkus (not reviewing)
2012/07/13 18:40:16
nit: we (media code) has typically put these along
DaleCurtis
2012/07/13 21:28:33
Done.
|
| +// on their AudioParameters configuration. Inputs with the same AudioParameters |
| +// configuration will share a mixer. While a new AudioRendererMixer will be |
|
scherkus (not reviewing)
2012/07/13 18:40:16
s/. While/ while/
DaleCurtis
2012/07/13 21:28:33
Done.
|
| +// 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. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| +#define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/synchronization/lock.h" |
| +#include "content/common/content_export.h" |
| +#include "media/audio/audio_parameters.h" |
| + |
| +namespace media { |
| +class AudioRendererMixer; |
| +class AudioRendererMixerInput; |
| +} |
| + |
| +class CONTENT_EXPORT AudioRendererMixerManager { |
|
jochen (gone - plz use gerrit)
2012/07/13 08:51:03
all code in content/ should go into namespace cont
DaleCurtis
2012/07/13 21:28:33
Done. I noticed the classes I was interacting wit
|
| + public: |
| + AudioRendererMixerManager(); |
| + virtual ~AudioRendererMixerManager(); |
|
scherkus (not reviewing)
2012/07/13 18:40:16
remove virtual -- I'm not seeing any virtualness i
DaleCurtis
2012/07/13 21:28:33
Done.
|
| + |
| + // Returns an AudioRendererMixerInput. |
| + scoped_refptr<media::AudioRendererMixerInput> CreateInput(); |
|
jochen (gone - plz use gerrit)
2012/07/13 08:51:03
why not just return a raw pointer? that way, the m
DaleCurtis
2012/07/13 21:28:33
Done.
|
| + |
| + private: |
| + friend class AudioRendererMixerManagerTest; |
|
jochen (gone - plz use gerrit)
2012/07/13 08:51:03
please use FRIEND_TEST_ALL_PREFIXES
DaleCurtis
2012/07/13 21:28:33
I don't think that's necessary here? I only access
|
| + |
| + // 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. RefCounting which |
| + // is implicit) of the number of outstanding AudioRendererMixers. |
| + typedef std::map<media::AudioParameters, |
| + std::pair<media::AudioRendererMixer*,int>, |
|
scherkus (not reviewing)
2012/07/13 18:40:16
s/,int/, int/
Alternatively can use a struct so c
DaleCurtis
2012/07/13 21:28:33
Done.
|
| + media::AudioParameters::Compare> AudioRendererMixerMap; |
| + AudioRendererMixerMap mixer_map_; |
| + base::Lock mixer_map_lock_; |
|
scherkus (not reviewing)
2012/07/13 18:40:16
which threads interact with this class requiring a
DaleCurtis
2012/07/13 21:28:33
ARMM is constructed on the render thread, GetMixer
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); |
| +}; |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |