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 // Audio rendering unit utilizing an AudioRendererSink to output data. | 5 // Audio rendering unit utilizing an AudioRendererSink to output data. |
6 // | 6 // |
7 // This class lives inside three threads during it's lifetime, namely: | 7 // This class lives inside three threads during it's lifetime, namely: |
8 // 1. Render thread | 8 // 1. Render thread |
9 // Where the object is created. | 9 // Where the object is created. |
10 // 2. Media thread (provided via constructor) | 10 // 2. Media thread (provided via constructor) |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "media/filters/audio_renderer_algorithm.h" | 31 #include "media/filters/audio_renderer_algorithm.h" |
32 #include "media/filters/decoder_stream.h" | 32 #include "media/filters/decoder_stream.h" |
33 | 33 |
34 namespace base { | 34 namespace base { |
35 class SingleThreadTaskRunner; | 35 class SingleThreadTaskRunner; |
36 } | 36 } |
37 | 37 |
38 namespace media { | 38 namespace media { |
39 | 39 |
40 class AudioBus; | 40 class AudioBus; |
41 class AudioBufferConverter; | |
41 class AudioSplicer; | 42 class AudioSplicer; |
42 class DecryptingDemuxerStream; | 43 class DecryptingDemuxerStream; |
44 class AudioHardwareConfig; | |
43 | 45 |
44 class MEDIA_EXPORT AudioRendererImpl | 46 class MEDIA_EXPORT AudioRendererImpl |
45 : public AudioRenderer, | 47 : public AudioRenderer, |
46 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { | 48 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
47 public: | 49 public: |
48 // |task_runner| is the thread on which AudioRendererImpl will execute. | 50 // |task_runner| is the thread on which AudioRendererImpl will execute. |
49 // | 51 // |
50 // |sink| is used as the destination for the rendered audio. | 52 // |sink| is used as the destination for the rendered audio. |
51 // | 53 // |
52 // |decoders| contains the AudioDecoders to use when initializing. | 54 // |decoders| contains the AudioDecoders to use when initializing. |
53 // | 55 // |
54 // |set_decryptor_ready_cb| is fired when the audio decryptor is available | 56 // |set_decryptor_ready_cb| is fired when the audio decryptor is available |
55 // (only applicable if the stream is encrypted and we have a decryptor). | 57 // (only applicable if the stream is encrypted and we have a decryptor). |
56 AudioRendererImpl( | 58 AudioRendererImpl( |
57 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 59 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
58 AudioRendererSink* sink, | 60 AudioRendererSink* sink, |
59 ScopedVector<AudioDecoder> decoders, | 61 ScopedVector<AudioDecoder> decoders, |
60 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 62 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
63 const AudioHardwareConfig& hardware_params); | |
61 virtual ~AudioRendererImpl(); | 64 virtual ~AudioRendererImpl(); |
62 | 65 |
63 // AudioRenderer implementation. | 66 // AudioRenderer implementation. |
64 virtual void Initialize(DemuxerStream* stream, | 67 virtual void Initialize(DemuxerStream* stream, |
65 const PipelineStatusCB& init_cb, | 68 const PipelineStatusCB& init_cb, |
66 const StatisticsCB& statistics_cb, | 69 const StatisticsCB& statistics_cb, |
67 const base::Closure& underflow_cb, | 70 const base::Closure& underflow_cb, |
68 const TimeCB& time_cb, | 71 const TimeCB& time_cb, |
69 const base::Closure& ended_cb, | 72 const base::Closure& ended_cb, |
70 const base::Closure& disabled_cb, | 73 const base::Closure& disabled_cb, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 // Calls |decoder_|.Reset() and arranges for ResetDecoderDone() to get | 178 // Calls |decoder_|.Reset() and arranges for ResetDecoderDone() to get |
176 // called when the reset completes. | 179 // called when the reset completes. |
177 void ResetDecoder(); | 180 void ResetDecoder(); |
178 | 181 |
179 // Called when the |decoder_|.Reset() has completed. | 182 // Called when the |decoder_|.Reset() has completed. |
180 void ResetDecoderDone(); | 183 void ResetDecoderDone(); |
181 | 184 |
182 // Called by the AudioBufferStream when a splice buffer is demuxed. | 185 // Called by the AudioBufferStream when a splice buffer is demuxed. |
183 void OnNewSpliceBuffer(base::TimeDelta); | 186 void OnNewSpliceBuffer(base::TimeDelta); |
184 | 187 |
188 // Called by the AudioBufferStream when a config change occurs. | |
189 void OnConfigChange(); | |
190 | |
185 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 191 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
186 | 192 |
187 scoped_ptr<AudioSplicer> splicer_; | 193 scoped_ptr<AudioSplicer> splicer_; |
194 scoped_ptr<AudioBufferConverter> buffer_converter_; | |
195 | |
196 // Whether or not we expect to handle config changes. | |
197 bool expecting_config_changes_; | |
188 | 198 |
189 // The sink (destination) for rendered audio. |sink_| must only be accessed | 199 // The sink (destination) for rendered audio. |sink_| must only be accessed |
190 // on |task_runner_|. |sink_| must never be called under |lock_| or else we | 200 // on |task_runner_|. |sink_| must never be called under |lock_| or else we |
191 // may deadlock between |task_runner_| and the audio callback thread. | 201 // may deadlock between |task_runner_| and the audio callback thread. |
192 scoped_refptr<media::AudioRendererSink> sink_; | 202 scoped_refptr<media::AudioRendererSink> sink_; |
193 | 203 |
194 AudioBufferStream audio_buffer_stream_; | 204 AudioBufferStream audio_buffer_stream_; |
195 | 205 |
196 // AudioParameters constructed during Initialize(). | 206 // Interface to the hardware audio params. |
207 const AudioHardwareConfig& hardware_config_; | |
DaleCurtis
2014/03/27 06:00:45
storing const& is unusual in CHrome land. I'd chec
rileya (GONE FROM CHROMIUM)
2014/03/27 17:51:40
Changed to a pointer.
| |
208 | |
209 // Cached copy of hardware params from |hardware_config_|. | |
197 AudioParameters audio_parameters_; | 210 AudioParameters audio_parameters_; |
198 | 211 |
199 // Callbacks provided during Initialize(). | 212 // Callbacks provided during Initialize(). |
200 PipelineStatusCB init_cb_; | 213 PipelineStatusCB init_cb_; |
201 base::Closure underflow_cb_; | 214 base::Closure underflow_cb_; |
202 TimeCB time_cb_; | 215 TimeCB time_cb_; |
203 base::Closure ended_cb_; | 216 base::Closure ended_cb_; |
204 base::Closure disabled_cb_; | 217 base::Closure disabled_cb_; |
205 PipelineStatusCB error_cb_; | 218 PipelineStatusCB error_cb_; |
206 | 219 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 | 280 |
268 // NOTE: Weak pointers must be invalidated before all other member variables. | 281 // NOTE: Weak pointers must be invalidated before all other member variables. |
269 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 282 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
270 | 283 |
271 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 284 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
272 }; | 285 }; |
273 | 286 |
274 } // namespace media | 287 } // namespace media |
275 | 288 |
276 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 289 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |