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 19 matching lines...) Expand all Loading... |
30 #include "media/base/decryptor.h" | 30 #include "media/base/decryptor.h" |
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 AudioBufferConverter; |
40 class AudioBus; | 41 class AudioBus; |
41 class AudioBufferConverter; | 42 class AudioClock; |
| 43 class AudioHardwareConfig; |
42 class AudioSplicer; | 44 class AudioSplicer; |
43 class DecryptingDemuxerStream; | 45 class DecryptingDemuxerStream; |
44 class AudioHardwareConfig; | |
45 | 46 |
46 class MEDIA_EXPORT AudioRendererImpl | 47 class MEDIA_EXPORT AudioRendererImpl |
47 : public AudioRenderer, | 48 : public AudioRenderer, |
48 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { | 49 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
49 public: | 50 public: |
50 // |task_runner| is the thread on which AudioRendererImpl will execute. | 51 // |task_runner| is the thread on which AudioRendererImpl will execute. |
51 // | 52 // |
52 // |sink| is used as the destination for the rendered audio. | 53 // |sink| is used as the destination for the rendered audio. |
53 // | 54 // |
54 // |decoders| contains the AudioDecoders to use when initializing. | 55 // |decoders| contains the AudioDecoders to use when initializing. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Keep track of whether or not the sink is playing. | 240 // Keep track of whether or not the sink is playing. |
240 bool sink_playing_; | 241 bool sink_playing_; |
241 | 242 |
242 // Keep track of our outstanding read to |decoder_|. | 243 // Keep track of our outstanding read to |decoder_|. |
243 bool pending_read_; | 244 bool pending_read_; |
244 | 245 |
245 // Keeps track of whether we received and rendered the end of stream buffer. | 246 // Keeps track of whether we received and rendered the end of stream buffer. |
246 bool received_end_of_stream_; | 247 bool received_end_of_stream_; |
247 bool rendered_end_of_stream_; | 248 bool rendered_end_of_stream_; |
248 | 249 |
249 // The timestamp of the last frame (i.e. furthest in the future) buffered as | 250 scoped_ptr<AudioClock> audio_clock_; |
250 // well as the current time that takes current playback delay into account. | |
251 base::TimeDelta audio_time_buffered_; | |
252 base::TimeDelta current_time_; | |
253 | 251 |
254 base::TimeDelta preroll_timestamp_; | 252 base::TimeDelta preroll_timestamp_; |
255 | 253 |
256 // We're supposed to know amount of audio data OS or hardware buffered, but | 254 // We're supposed to know amount of audio data OS or hardware buffered, but |
257 // that is not always so -- on my Linux box | 255 // that is not always so -- on my Linux box |
258 // AudioBuffersState::hardware_delay_bytes never reaches 0. | 256 // AudioBuffersState::hardware_delay_bytes never reaches 0. |
259 // | 257 // |
260 // As a result we cannot use it to find when stream ends. If we just ignore | 258 // As a result we cannot use it to find when stream ends. If we just ignore |
261 // buffered data we will notify host that stream ended before it is actually | 259 // buffered data we will notify host that stream ended before it is actually |
262 // did so, I've seen it done ~140ms too early when playing ~150ms file. | 260 // did so, I've seen it done ~140ms too early when playing ~150ms file. |
(...skipping 17 matching lines...) Expand all Loading... |
280 | 278 |
281 // NOTE: Weak pointers must be invalidated before all other member variables. | 279 // NOTE: Weak pointers must be invalidated before all other member variables. |
282 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 280 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
283 | 281 |
284 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 282 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
285 }; | 283 }; |
286 | 284 |
287 } // namespace media | 285 } // namespace media |
288 | 286 |
289 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 287 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |