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

Side by Side 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: Add virtual GetAudioHardwareParameters() method. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
7
8 #include <map>
9
10 #include "base/synchronization/lock.h"
11 #include "content/common/content_export.h"
12 #include "media/audio/audio_parameters.h"
13
14 namespace media {
15 class AudioRendererMixer;
16 class AudioRendererMixerInput;
17 }
18
19 namespace content {
20
21 // Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based
22 // on their AudioParameters configuration. Inputs with the same AudioParameters
23 // configuration will share a mixer while a new AudioRendererMixer will be
24 // lazily created if one with the exact AudioParameters does not exist.
25 //
26 // There should only be one instance of AudioRendererMixerManager per render
27 // thread.
28 //
29 // TODO(dalecurtis): Right now we require AudioParameters to be an exact match
30 // when we should be able to ignore bits per channel since we're only dealing
31 // with floats. However, bits per channel is currently used to interleave the
32 // audio data by AudioDevice::AudioThreadCallback::Process for consumption via
33 // the shared memory. See http://crbug.com/114700.
34 class CONTENT_EXPORT AudioRendererMixerManager {
35 public:
36 AudioRendererMixerManager();
37 virtual ~AudioRendererMixerManager();
38
39 // Creates an AudioRendererMixerInput with the proper callbacks necessary to
40 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager.
41 // Caller must ensure AudioRendererMixerManager outlives the returned input.
42 media::AudioRendererMixerInput* CreateInput();
43
44 protected:
45 // Given a set of input parameters, returns the proper output parameters based
46 // on hardware configuration; allows unit tests to subclass and avoid real
47 // hardware dependencies.
48 virtual media::AudioParameters GetAudioHardwareParameters(
49 const media::AudioParameters& params);
50
51 private:
52 friend class AudioRendererMixerManagerTest;
53
54 // Returns a mixer instance based on AudioParameters; an existing one if one
55 // with the provided AudioParameters exists or a new one if not.
56 media::AudioRendererMixer* GetMixer(const media::AudioParameters& params);
57
58 // Remove a mixer instance given a mixer if the only other reference is held
59 // by AudioRendererMixerManager. Every AudioRendererMixer owner must call
60 // this method when it's done with a mixer.
61 void RemoveMixer(const media::AudioParameters& params);
62
63 // Map of AudioParameters to <AudioRendererMixer, Count>. Count allows
64 // AudioRendererMixerManager to keep track explicitly (v.s. RefCounted which
65 // is implicit) of the number of outstanding AudioRendererMixers.
66 struct AudioRendererMixerReference {
67 media::AudioRendererMixer* mixer;
68 int ref_count;
69 };
70 typedef std::map<media::AudioParameters, AudioRendererMixerReference,
71 media::AudioParameters::Compare> AudioRendererMixerMap;
72 AudioRendererMixerMap mixers_;
73 base::Lock mixers_lock_;
74
75 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager);
76 };
77
78 } // namespace content
79
80 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698