Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: media/filters/audio_renderer_impl.h

Issue 141243003: Add AudioBufferStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decoderstream_rebased
Patch Set: Rebase! Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
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/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
27 #include "media/base/audio_decoder.h" 27 #include "media/base/audio_decoder.h"
28 #include "media/base/audio_renderer.h" 28 #include "media/base/audio_renderer.h"
29 #include "media/base/audio_renderer_sink.h" 29 #include "media/base/audio_renderer_sink.h"
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_selector.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 AudioSplicer; 41 class AudioSplicer;
42 class DecryptingDemuxerStream; 42 class DecryptingDemuxerStream;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 kPaused, 101 kPaused,
102 kFlushing, 102 kFlushing,
103 kPrerolling, 103 kPrerolling,
104 kPlaying, 104 kPlaying,
105 kStopped, 105 kStopped,
106 kUnderflow, 106 kUnderflow,
107 kRebuffering, 107 kRebuffering,
108 }; 108 };
109 109
110 // Callback from the audio decoder delivering decoded audio samples. 110 // Callback from the audio decoder delivering decoded audio samples.
111 void DecodedAudioReady(AudioDecoder::Status status, 111 void DecodedAudioReady(AudioBufferStream::Status status,
112 const scoped_refptr<AudioBuffer>& buffer); 112 const scoped_refptr<AudioBuffer>& buffer);
113 113
114 // Handles buffers that come out of |splicer_|. 114 // Handles buffers that come out of |splicer_|.
115 // Returns true if more buffers are needed. 115 // Returns true if more buffers are needed.
116 bool HandleSplicerBuffer(const scoped_refptr<AudioBuffer>& buffer); 116 bool HandleSplicerBuffer(const scoped_refptr<AudioBuffer>& buffer);
117 117
118 // Helper functions for AudioDecoder::Status values passed to 118 // Helper functions for AudioDecoder::Status values passed to
119 // DecodedAudioReady(). 119 // DecodedAudioReady().
120 void HandleAbortedReadOrDecodeError(bool is_decode_error); 120 void HandleAbortedReadOrDecodeError(bool is_decode_error);
121 121
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void AttemptRead(); 157 void AttemptRead();
158 void AttemptRead_Locked(); 158 void AttemptRead_Locked();
159 bool CanRead_Locked(); 159 bool CanRead_Locked();
160 void ChangeState_Locked(State new_state); 160 void ChangeState_Locked(State new_state);
161 161
162 // Returns true if the data in the buffer is all before 162 // Returns true if the data in the buffer is all before
163 // |preroll_timestamp_|. This can only return true while 163 // |preroll_timestamp_|. This can only return true while
164 // in the kPrerolling state. 164 // in the kPrerolling state.
165 bool IsBeforePrerollTime(const scoped_refptr<AudioBuffer>& buffer); 165 bool IsBeforePrerollTime(const scoped_refptr<AudioBuffer>& buffer);
166 166
167 // Called when |decoder_selector_| has selected |decoder| or is null if no 167 // Called upon AudioBufferStream initialization, or failure thereof (indicated
168 // decoder could be selected. 168 // by the value of |success|).
169 // 169 void OnAudioBufferStreamInitialized(bool succes);
170 // |decrypting_demuxer_stream| is non-null if a DecryptingDemuxerStream was
171 // created to help decrypt the encrypted stream.
172 void OnDecoderSelected(
173 scoped_ptr<AudioDecoder> decoder,
174 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream);
175 170
176 // Used to initiate the flush operation once all pending reads have 171 // Used to initiate the flush operation once all pending reads have
177 // completed. 172 // completed.
178 void DoFlush_Locked(); 173 void DoFlush_Locked();
179 174
180 // Calls |decoder_|.Reset() and arranges for ResetDecoderDone() to get 175 // Calls |decoder_|.Reset() and arranges for ResetDecoderDone() to get
181 // called when the reset completes. 176 // called when the reset completes.
182 void ResetDecoder(); 177 void ResetDecoder();
183 178
184 // Called when the |decoder_|.Reset() has completed. 179 // Called when the |decoder_|.Reset() has completed.
185 void ResetDecoderDone(); 180 void ResetDecoderDone();
186 181
187 // Stops the |decoder_| if present. Ensures |stop_cb_| is called.
188 void StopDecoder();
189
190 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 182 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
191 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; 183 base::WeakPtrFactory<AudioRendererImpl> weak_factory_;
192 base::WeakPtr<AudioRendererImpl> weak_this_; 184 base::WeakPtr<AudioRendererImpl> weak_this_;
193 185
194 scoped_ptr<AudioSplicer> splicer_; 186 scoped_ptr<AudioSplicer> splicer_;
195 187
196 // The sink (destination) for rendered audio. |sink_| must only be accessed 188 // The sink (destination) for rendered audio. |sink_| must only be accessed
197 // on |task_runner_|. |sink_| must never be called under |lock_| or else we 189 // on |task_runner_|. |sink_| must never be called under |lock_| or else we
198 // may deadlock between |task_runner_| and the audio callback thread. 190 // may deadlock between |task_runner_| and the audio callback thread.
199 scoped_refptr<media::AudioRendererSink> sink_; 191 scoped_refptr<media::AudioRendererSink> sink_;
200 192
201 scoped_ptr<AudioDecoderSelector> decoder_selector_; 193 AudioBufferStream audio_buffer_stream_;
202 194
203 // These two will be set by AudioDecoderSelector::SelectAudioDecoder(). 195 // AudioParameters constructed during Initialize().
204 scoped_ptr<AudioDecoder> decoder_;
205 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
206
207 // AudioParameters constructed during Initialize() based on |decoder_|.
208 AudioParameters audio_parameters_; 196 AudioParameters audio_parameters_;
209 197
210 // Callbacks provided during Initialize(). 198 // Callbacks provided during Initialize().
211 PipelineStatusCB init_cb_; 199 PipelineStatusCB init_cb_;
212 StatisticsCB statistics_cb_;
213 base::Closure underflow_cb_; 200 base::Closure underflow_cb_;
214 TimeCB time_cb_; 201 TimeCB time_cb_;
215 base::Closure ended_cb_; 202 base::Closure ended_cb_;
216 base::Closure disabled_cb_; 203 base::Closure disabled_cb_;
217 PipelineStatusCB error_cb_; 204 PipelineStatusCB error_cb_;
218 205
219 // Callback provided to Flush(). 206 // Callback provided to Flush().
220 base::Closure flush_cb_; 207 base::Closure flush_cb_;
221 208
222 // Callback provided to Stop().
223 base::Closure stop_cb_;
224
225 // Callback provided to Preroll(). 209 // Callback provided to Preroll().
226 PipelineStatusCB preroll_cb_; 210 PipelineStatusCB preroll_cb_;
227 211
228 // Typically calls base::TimeTicks::Now() but can be overridden by a test. 212 // Typically calls base::TimeTicks::Now() but can be overridden by a test.
229 NowCB now_cb_; 213 NowCB now_cb_;
230 214
231 // After Initialize() has completed, all variables below must be accessed 215 // After Initialize() has completed, all variables below must be accessed
232 // under |lock_|. ------------------------------------------------------------ 216 // under |lock_|. ------------------------------------------------------------
233 base::Lock lock_; 217 base::Lock lock_;
234 218
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 bool preroll_aborted_; 263 bool preroll_aborted_;
280 264
281 // End variables which must be accessed under |lock_|. ---------------------- 265 // End variables which must be accessed under |lock_|. ----------------------
282 266
283 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 267 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
284 }; 268 };
285 269
286 } // namespace media 270 } // namespace media
287 271
288 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 272 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698