Chromium Code Reviews| 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. |
| 39 AudioRendererMixerManager(int hardware_sample_rate, int hardware_buffer_size); | 40 AudioRendererMixerManager(media::AudioHardwareConfig* hardware_config); |
|
scherkus (not reviewing)
2013/01/31 02:33:33
raw pointer scares me -- care to document the life
miu
2013/01/31 05:28:53
Drive-by comment: Add 'explicit' keyword here.
DaleCurtis
2013/01/31 19:50:00
Done.
DaleCurtis
2013/01/31 19:50:00
Done.
| |
| 40 ~AudioRendererMixerManager(); | 41 ~AudioRendererMixerManager(); |
| 41 | 42 |
| 42 // Creates an AudioRendererMixerInput with the proper callbacks necessary to | 43 // Creates an AudioRendererMixerInput with the proper callbacks necessary to |
| 43 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. | 44 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. |
| 44 // |source_render_view_id| refers to the RenderView containing the entity | 45 // |source_render_view_id| refers to the RenderView containing the entity |
| 45 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives | 46 // rendering the audio. Caller must ensure AudioRendererMixerManager outlives |
| 46 // the returned input. | 47 // the returned input. |
| 47 media::AudioRendererMixerInput* CreateInput(int source_render_view_id); | 48 media::AudioRendererMixerInput* CreateInput(int source_render_view_id); |
| 48 | 49 |
| 49 private: | 50 private: |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 75 // this method when it's done with a mixer. | 76 // this method when it's done with a mixer. |
| 76 void RemoveMixer(int source_render_view_id, | 77 void RemoveMixer(int source_render_view_id, |
| 77 const media::AudioParameters& params); | 78 const media::AudioParameters& params); |
| 78 | 79 |
| 79 // Active mixers. | 80 // Active mixers. |
| 80 AudioRendererMixerMap mixers_; | 81 AudioRendererMixerMap mixers_; |
| 81 base::Lock mixers_lock_; | 82 base::Lock mixers_lock_; |
| 82 | 83 |
| 83 // Audio hardware configuration. Used to construct output AudioParameters for | 84 // Audio hardware configuration. Used to construct output AudioParameters for |
| 84 // each AudioRendererMixer instance. | 85 // each AudioRendererMixer instance. |
| 85 int hardware_sample_rate_; | 86 media::AudioHardwareConfig* const hardware_config_; |
| 86 int hardware_buffer_size_; | |
| 87 | 87 |
| 88 media::AudioRendererSink* sink_for_testing_; | 88 media::AudioRendererSink* sink_for_testing_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); | 90 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace content | 93 } // namespace content |
| 94 | 94 |
| 95 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ | 95 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ |
| OLD | NEW |