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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 void StartTicking() override; | 72 void StartTicking() override; |
73 void StopTicking() override; | 73 void StopTicking() override; |
74 void SetPlaybackRate(double rate) override; | 74 void SetPlaybackRate(double rate) override; |
75 void SetMediaTime(base::TimeDelta time) override; | 75 void SetMediaTime(base::TimeDelta time) override; |
76 base::TimeDelta CurrentMediaTime() override; | 76 base::TimeDelta CurrentMediaTime() override; |
77 bool GetWallClockTimes( | 77 bool GetWallClockTimes( |
78 const std::vector<base::TimeDelta>& media_timestamps, | 78 const std::vector<base::TimeDelta>& media_timestamps, |
79 std::vector<base::TimeTicks>* wall_clock_times) override; | 79 std::vector<base::TimeTicks>* wall_clock_times) override; |
80 | 80 |
81 // AudioRenderer implementation. | 81 // AudioRenderer implementation. |
82 void Initialize(DemuxerStream* stream, | 82 void Initialize(RendererClient* client, |
83 const PipelineStatusCB& init_cb, | 83 DemuxerStream* stream, |
84 CdmContext* cdm_context, | 84 CdmContext* cdm_context, |
85 const StatisticsCB& statistics_cb, | 85 const PipelineStatusCB& init_cb) override; |
86 const BufferingStateCB& buffering_state_cb, | |
87 const base::Closure& ended_cb, | |
88 const PipelineStatusCB& error_cb, | |
89 const base::Closure& waiting_for_decryption_key_cb) override; | |
90 TimeSource* GetTimeSource() override; | 86 TimeSource* GetTimeSource() override; |
91 void Flush(const base::Closure& callback) override; | 87 void Flush(const base::Closure& callback) override; |
92 void StartPlaying() override; | 88 void StartPlaying() override; |
93 void SetVolume(float volume) override; | 89 void SetVolume(float volume) override; |
94 | 90 |
95 private: | 91 private: |
96 friend class AudioRendererImplTest; | 92 friend class AudioRendererImplTest; |
97 | 93 |
98 // Important detail: being in kPlaying doesn't imply that audio is being | 94 // Important detail: being in kPlaying doesn't imply that audio is being |
99 // rendered. Rather, it means that the renderer is ready to go. The actual | 95 // rendered. Rather, it means that the renderer is ready to go. The actual |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 void AttemptRead_Locked(); | 163 void AttemptRead_Locked(); |
168 bool CanRead_Locked(); | 164 bool CanRead_Locked(); |
169 void ChangeState_Locked(State new_state); | 165 void ChangeState_Locked(State new_state); |
170 | 166 |
171 // Returns true if the data in the buffer is all before |start_timestamp_|. | 167 // Returns true if the data in the buffer is all before |start_timestamp_|. |
172 // This can only return true while in the kPlaying state. | 168 // This can only return true while in the kPlaying state. |
173 bool IsBeforeStartTime(const scoped_refptr<AudioBuffer>& buffer); | 169 bool IsBeforeStartTime(const scoped_refptr<AudioBuffer>& buffer); |
174 | 170 |
175 // Called upon AudioBufferStream initialization, or failure thereof (indicated | 171 // Called upon AudioBufferStream initialization, or failure thereof (indicated |
176 // by the value of |success|). | 172 // by the value of |success|). |
177 void OnAudioBufferStreamInitialized(bool succes); | 173 void OnAudioBufferStreamInitialized(bool succes); |
xhwang
2016/05/09 18:13:23
Add an empty line here since the comment above onl
alokp
2016/05/09 21:31:44
Done.
| |
174 void OnPlaybackError(PipelineStatus error); | |
xhwang
2016/05/09 18:13:22
Add comment for this group, e.g. callbacks for the
alokp
2016/05/09 21:31:44
Done.
| |
175 void OnPlaybackEnded(); | |
176 void OnStatisticsUpdate(const PipelineStatistics& stats); | |
177 void OnBufferingStateChange(BufferingState state); | |
178 void OnWaitingForDecryptionKey(); | |
178 | 179 |
179 // Used to initiate the flush operation once all pending reads have | 180 // Used to initiate the flush operation once all pending reads have |
180 // completed. | 181 // completed. |
181 void DoFlush_Locked(); | 182 void DoFlush_Locked(); |
182 | 183 |
183 // Called when the |decoder_|.Reset() has completed. | 184 // Called when the |decoder_|.Reset() has completed. |
184 void ResetDecoderDone(); | 185 void ResetDecoderDone(); |
185 | 186 |
186 // Called by the AudioBufferStream when a splice buffer is demuxed. | 187 // Called by the AudioBufferStream when a splice buffer is demuxed. |
187 void OnNewSpliceBuffer(base::TimeDelta); | 188 void OnNewSpliceBuffer(base::TimeDelta); |
(...skipping 20 matching lines...) Expand all Loading... | |
208 std::unique_ptr<AudioBufferStream> audio_buffer_stream_; | 209 std::unique_ptr<AudioBufferStream> audio_buffer_stream_; |
209 | 210 |
210 // Interface to the hardware audio params. | 211 // Interface to the hardware audio params. |
211 const AudioHardwareConfig& hardware_config_; | 212 const AudioHardwareConfig& hardware_config_; |
212 | 213 |
213 scoped_refptr<MediaLog> media_log_; | 214 scoped_refptr<MediaLog> media_log_; |
214 | 215 |
215 // Cached copy of hardware params from |hardware_config_|. | 216 // Cached copy of hardware params from |hardware_config_|. |
216 AudioParameters audio_parameters_; | 217 AudioParameters audio_parameters_; |
217 | 218 |
218 // Callbacks provided during Initialize(). | 219 RendererClient* client_; |
220 | |
221 // Callback provided during Initialize(). | |
219 PipelineStatusCB init_cb_; | 222 PipelineStatusCB init_cb_; |
220 BufferingStateCB buffering_state_cb_; | |
221 base::Closure ended_cb_; | |
222 PipelineStatusCB error_cb_; | |
223 StatisticsCB statistics_cb_; | |
224 | 223 |
225 // Callback provided to Flush(). | 224 // Callback provided to Flush(). |
226 base::Closure flush_cb_; | 225 base::Closure flush_cb_; |
227 | 226 |
228 // Overridable tick clock for testing. | 227 // Overridable tick clock for testing. |
229 std::unique_ptr<base::TickClock> tick_clock_; | 228 std::unique_ptr<base::TickClock> tick_clock_; |
230 | 229 |
231 // Memory usage of |algorithm_| recorded during the last | 230 // Memory usage of |algorithm_| recorded during the last |
232 // HandleSplicerBuffer_Locked() call. | 231 // HandleSplicerBuffer_Locked() call. |
233 int64_t last_audio_memory_usage_; | 232 int64_t last_audio_memory_usage_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 | 291 |
293 // NOTE: Weak pointers must be invalidated before all other member variables. | 292 // NOTE: Weak pointers must be invalidated before all other member variables. |
294 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 293 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
295 | 294 |
296 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 295 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
297 }; | 296 }; |
298 | 297 |
299 } // namespace media | 298 } // namespace media |
300 | 299 |
301 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 300 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |