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) |
11 // All AudioDecoder methods are called on this thread. | 11 // All AudioDecoder methods are called on this thread. |
12 // 3. Audio thread created by the AudioRendererSink. | 12 // 3. Audio thread created by the AudioRendererSink. |
13 // Render() is called here where audio data is decoded into raw PCM data. | 13 // Render() is called here where audio data is decoded into raw PCM data. |
14 // | 14 // |
15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of | 15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of |
16 // queueing audio data and stretching/shrinking audio data when playback rate != | 16 // queueing audio data and stretching/shrinking audio data when playback rate != |
17 // 1.0 or 0.0. | 17 // 1.0 or 0.0. |
18 | 18 |
19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
20 #define MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 20 #define MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
21 | 21 |
22 #include <deque> | 22 #include <deque> |
23 | 23 |
24 #include "base/gtest_prod_util.h" | 24 #include "base/gtest_prod_util.h" |
| 25 #include "base/memory/scoped_ptr.h" |
25 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
26 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.h" |
27 #include "media/base/audio_decoder.h" | 28 #include "media/base/audio_decoder.h" |
28 #include "media/base/audio_renderer.h" | 29 #include "media/base/audio_renderer.h" |
29 #include "media/base/audio_renderer_sink.h" | 30 #include "media/base/audio_renderer_sink.h" |
30 #include "media/base/decryptor.h" | 31 #include "media/base/decryptor.h" |
31 #include "media/filters/audio_renderer_algorithm.h" | 32 #include "media/filters/audio_renderer_algorithm.h" |
32 #include "media/filters/decoder_stream.h" | 33 #include "media/filters/decoder_stream.h" |
33 | 34 |
34 namespace base { | 35 namespace base { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 scoped_ptr<AudioBufferConverter> buffer_converter_; | 191 scoped_ptr<AudioBufferConverter> buffer_converter_; |
191 | 192 |
192 // Whether or not we expect to handle config changes. | 193 // Whether or not we expect to handle config changes. |
193 bool expecting_config_changes_; | 194 bool expecting_config_changes_; |
194 | 195 |
195 // The sink (destination) for rendered audio. |sink_| must only be accessed | 196 // The sink (destination) for rendered audio. |sink_| must only be accessed |
196 // on |task_runner_|. |sink_| must never be called under |lock_| or else we | 197 // on |task_runner_|. |sink_| must never be called under |lock_| or else we |
197 // may deadlock between |task_runner_| and the audio callback thread. | 198 // may deadlock between |task_runner_| and the audio callback thread. |
198 scoped_refptr<media::AudioRendererSink> sink_; | 199 scoped_refptr<media::AudioRendererSink> sink_; |
199 | 200 |
200 AudioBufferStream audio_buffer_stream_; | 201 scoped_ptr<AudioBufferStream> audio_buffer_stream_; |
201 | 202 |
202 // Interface to the hardware audio params. | 203 // Interface to the hardware audio params. |
203 const AudioHardwareConfig* const hardware_config_; | 204 const AudioHardwareConfig* const hardware_config_; |
204 | 205 |
205 // Cached copy of hardware params from |hardware_config_|. | 206 // Cached copy of hardware params from |hardware_config_|. |
206 AudioParameters audio_parameters_; | 207 AudioParameters audio_parameters_; |
207 | 208 |
208 // Callbacks provided during Initialize(). | 209 // Callbacks provided during Initialize(). |
209 PipelineStatusCB init_cb_; | 210 PipelineStatusCB init_cb_; |
210 TimeCB time_cb_; | 211 TimeCB time_cb_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 248 |
248 // NOTE: Weak pointers must be invalidated before all other member variables. | 249 // NOTE: Weak pointers must be invalidated before all other member variables. |
249 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 250 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
250 | 251 |
251 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 252 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
252 }; | 253 }; |
253 | 254 |
254 } // namespace media | 255 } // namespace media |
255 | 256 |
256 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 257 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |