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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const AudioHardwareConfig& hardware_params, | 68 const AudioHardwareConfig& hardware_params, |
69 const scoped_refptr<MediaLog>& media_log); | 69 const scoped_refptr<MediaLog>& media_log); |
70 virtual ~AudioRendererImpl(); | 70 virtual ~AudioRendererImpl(); |
71 | 71 |
72 // TimeSource implementation. | 72 // TimeSource implementation. |
73 virtual void StartTicking() OVERRIDE; | 73 virtual void StartTicking() OVERRIDE; |
74 virtual void StopTicking() OVERRIDE; | 74 virtual void StopTicking() OVERRIDE; |
75 virtual void SetPlaybackRate(float rate) OVERRIDE; | 75 virtual void SetPlaybackRate(float rate) OVERRIDE; |
76 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; | 76 virtual void SetMediaTime(base::TimeDelta time) OVERRIDE; |
77 virtual base::TimeDelta CurrentMediaTime() OVERRIDE; | 77 virtual base::TimeDelta CurrentMediaTime() OVERRIDE; |
78 virtual base::TimeDelta CurrentMediaTimeForSyncingVideo() OVERRIDE; | |
79 | 78 |
80 // AudioRenderer implementation. | 79 // AudioRenderer implementation. |
81 virtual void Initialize(DemuxerStream* stream, | 80 virtual void Initialize(DemuxerStream* stream, |
82 const PipelineStatusCB& init_cb, | 81 const PipelineStatusCB& init_cb, |
83 const StatisticsCB& statistics_cb, | 82 const StatisticsCB& statistics_cb, |
| 83 const TimeCB& time_cb, |
84 const BufferingStateCB& buffering_state_cb, | 84 const BufferingStateCB& buffering_state_cb, |
85 const base::Closure& ended_cb, | 85 const base::Closure& ended_cb, |
86 const PipelineStatusCB& error_cb) OVERRIDE; | 86 const PipelineStatusCB& error_cb) OVERRIDE; |
87 virtual TimeSource* GetTimeSource() OVERRIDE; | 87 virtual TimeSource* GetTimeSource() OVERRIDE; |
88 virtual void Flush(const base::Closure& callback) OVERRIDE; | 88 virtual void Flush(const base::Closure& callback) OVERRIDE; |
89 virtual void StartPlaying() OVERRIDE; | 89 virtual void StartPlaying() OVERRIDE; |
90 virtual void SetVolume(float volume) OVERRIDE; | 90 virtual void SetVolume(float volume) OVERRIDE; |
91 | 91 |
92 private: | 92 private: |
93 friend class AudioRendererImplTest; | 93 friend class AudioRendererImplTest; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 scoped_ptr<AudioBufferStream> audio_buffer_stream_; | 208 scoped_ptr<AudioBufferStream> audio_buffer_stream_; |
209 | 209 |
210 // Interface to the hardware audio params. | 210 // Interface to the hardware audio params. |
211 const AudioHardwareConfig& hardware_config_; | 211 const AudioHardwareConfig& hardware_config_; |
212 | 212 |
213 // Cached copy of hardware params from |hardware_config_|. | 213 // Cached copy of hardware params from |hardware_config_|. |
214 AudioParameters audio_parameters_; | 214 AudioParameters audio_parameters_; |
215 | 215 |
216 // Callbacks provided during Initialize(). | 216 // Callbacks provided during Initialize(). |
217 PipelineStatusCB init_cb_; | 217 PipelineStatusCB init_cb_; |
| 218 TimeCB time_cb_; |
218 BufferingStateCB buffering_state_cb_; | 219 BufferingStateCB buffering_state_cb_; |
219 base::Closure ended_cb_; | 220 base::Closure ended_cb_; |
220 PipelineStatusCB error_cb_; | 221 PipelineStatusCB error_cb_; |
221 | 222 |
222 // Callback provided to Flush(). | 223 // Callback provided to Flush(). |
223 base::Closure flush_cb_; | 224 base::Closure flush_cb_; |
224 | 225 |
225 // After Initialize() has completed, all variables below must be accessed | 226 // After Initialize() has completed, all variables below must be accessed |
226 // under |lock_|. ------------------------------------------------------------ | 227 // under |lock_|. ------------------------------------------------------------ |
227 base::Lock lock_; | 228 base::Lock lock_; |
(...skipping 14 matching lines...) Expand all Loading... |
242 | 243 |
243 // Keep track of our outstanding read to |decoder_|. | 244 // Keep track of our outstanding read to |decoder_|. |
244 bool pending_read_; | 245 bool pending_read_; |
245 | 246 |
246 // Keeps track of whether we received and rendered the end of stream buffer. | 247 // Keeps track of whether we received and rendered the end of stream buffer. |
247 bool received_end_of_stream_; | 248 bool received_end_of_stream_; |
248 bool rendered_end_of_stream_; | 249 bool rendered_end_of_stream_; |
249 | 250 |
250 scoped_ptr<AudioClock> audio_clock_; | 251 scoped_ptr<AudioClock> audio_clock_; |
251 | 252 |
252 // The media timestamp to begin playback at after seeking. Set via | |
253 // SetMediaTime(). | |
254 base::TimeDelta start_timestamp_; | 253 base::TimeDelta start_timestamp_; |
255 | |
256 // The media timestamp to signal end of audio playback. Determined during | |
257 // Render() when writing the final frames of decoded audio data. | |
258 base::TimeDelta ended_timestamp_; | 254 base::TimeDelta ended_timestamp_; |
259 | 255 base::TimeDelta last_timestamp_update_; |
260 // Set every Render() and used to provide an interpolated time value to | |
261 // CurrentMediaTimeForSyncingVideo(). | |
262 base::TimeTicks last_render_ticks_; | |
263 | 256 |
264 // End variables which must be accessed under |lock_|. ---------------------- | 257 // End variables which must be accessed under |lock_|. ---------------------- |
265 | 258 |
266 // NOTE: Weak pointers must be invalidated before all other member variables. | 259 // NOTE: Weak pointers must be invalidated before all other member variables. |
267 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 260 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
268 | 261 |
269 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 262 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
270 }; | 263 }; |
271 | 264 |
272 } // namespace media | 265 } // namespace media |
273 | 266 |
274 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 267 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |