OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
| 16 class AudioHardwareConfig; |
16 class AudioRendererMixer; | 17 class AudioRendererMixer; |
17 class AudioRendererMixerInput; | 18 class AudioRendererMixerInput; |
18 class AudioRendererSink; | 19 class AudioRendererSink; |
19 } | 20 } |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 // Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based | 24 // Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based |
24 // on their AudioParameters configuration. Inputs with the same AudioParameters | 25 // on their AudioParameters configuration. Inputs with the same AudioParameters |
25 // configuration will share a mixer while a new AudioRendererMixer will be | 26 // configuration will share a mixer while a new AudioRendererMixer will be |
26 // lazily created if one with the exact AudioParameters does not exist. | 27 // lazily created if one with the exact AudioParameters does not exist. |
27 // | 28 // |
28 // There should only be one instance of AudioRendererMixerManager per render | 29 // There should only be one instance of AudioRendererMixerManager per render |
29 // thread. | 30 // thread. |
30 // | 31 // |
31 // TODO(dalecurtis): Right now we require AudioParameters to be an exact match | 32 // TODO(dalecurtis): Right now we require AudioParameters to be an exact match |
32 // when we should be able to ignore bits per channel since we're only dealing | 33 // when we should be able to ignore bits per channel since we're only dealing |
33 // with floats. However, bits per channel is currently used to interleave the | 34 // with floats. However, bits per channel is currently used to interleave the |
34 // audio data by AudioOutputDevice::AudioThreadCallback::Process for consumption | 35 // audio data by AudioOutputDevice::AudioThreadCallback::Process for consumption |
35 // via the shared memory. See http://crbug.com/114700. | 36 // via the shared memory. See http://crbug.com/114700. |
36 class CONTENT_EXPORT AudioRendererMixerManager { | 37 class CONTENT_EXPORT AudioRendererMixerManager { |
37 public: | 38 public: |
38 // Construct an instance using the given audio hardware configuration. | 39 // Construct an instance using the given audio hardware configuration. The |
39 AudioRendererMixerManager(int hardware_sample_rate, int hardware_buffer_size); | 40 // provided |hardware_config| is not owned by AudioRendererMixerManager and |
| 41 // must outlive it. |
| 42 explicit AudioRendererMixerManager( |
| 43 media::AudioHardwareConfig* hardware_config); |
40 ~AudioRendererMixerManager(); | 44 ~AudioRendererMixerManager(); |
41 | 45 |
42 // Creates an AudioRendererMixerInput with the proper callbacks necessary to | 46 // Creates an AudioRendererMixerInput with the proper callbacks necessary to |
43 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. | 47 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. |
44 // |source_render_view_id| refers to the RenderView containing the entity | 48 // |source_render_view_id| refers to the RenderView containing the entity |
45 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives | 49 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives |
46 // the returned input. | 50 // the returned input. |
47 media::AudioRendererMixerInput* CreateInput(int source_render_view_id); | 51 media::AudioRendererMixerInput* CreateInput(int source_render_view_id); |
48 | 52 |
49 private: | 53 private: |
(...skipping 25 matching lines...) Expand all Loading... |
75 // this method when it's done with a mixer. | 79 // this method when it's done with a mixer. |
76 void RemoveMixer(int source_render_view_id, | 80 void RemoveMixer(int source_render_view_id, |
77 const media::AudioParameters& params); | 81 const media::AudioParameters& params); |
78 | 82 |
79 // Active mixers. | 83 // Active mixers. |
80 AudioRendererMixerMap mixers_; | 84 AudioRendererMixerMap mixers_; |
81 base::Lock mixers_lock_; | 85 base::Lock mixers_lock_; |
82 | 86 |
83 // Audio hardware configuration. Used to construct output AudioParameters for | 87 // Audio hardware configuration. Used to construct output AudioParameters for |
84 // each AudioRendererMixer instance. | 88 // each AudioRendererMixer instance. |
85 int hardware_sample_rate_; | 89 media::AudioHardwareConfig* const hardware_config_; |
86 int hardware_buffer_size_; | |
87 | 90 |
88 media::AudioRendererSink* sink_for_testing_; | 91 media::AudioRendererSink* sink_for_testing_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); | 93 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace content | 96 } // namespace content |
94 | 97 |
95 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 98 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
OLD | NEW |