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

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

Issue 13813016: Remove reference counting from media::Demuxer and friends. (Closed) Base URL: http://git.chromium.org/chromium/src.git@vd_scoped
Patch Set: Created 7 years, 8 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
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 #include "media/filters/audio_renderer_impl.h" 5 #include "media/filters/audio_renderer_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 splicer_->Reset(); 172 splicer_->Reset();
173 algorithm_->FlushBuffers(); 173 algorithm_->FlushBuffers();
174 earliest_end_time_ = now_cb_.Run(); 174 earliest_end_time_ = now_cb_.Run();
175 175
176 AttemptRead_Locked(); 176 AttemptRead_Locked();
177 } 177 }
178 178
179 sink_->Pause(); 179 sink_->Pause();
180 } 180 }
181 181
182 void AudioRendererImpl::Initialize(const scoped_refptr<DemuxerStream>& stream, 182 void AudioRendererImpl::Initialize(DemuxerStream* stream,
183 const PipelineStatusCB& init_cb, 183 const PipelineStatusCB& init_cb,
184 const StatisticsCB& statistics_cb, 184 const StatisticsCB& statistics_cb,
185 const base::Closure& underflow_cb, 185 const base::Closure& underflow_cb,
186 const TimeCB& time_cb, 186 const TimeCB& time_cb,
187 const base::Closure& ended_cb, 187 const base::Closure& ended_cb,
188 const base::Closure& disabled_cb, 188 const base::Closure& disabled_cb,
189 const PipelineStatusCB& error_cb) { 189 const PipelineStatusCB& error_cb) {
190 DCHECK(message_loop_->BelongsToCurrentThread()); 190 DCHECK(message_loop_->BelongsToCurrentThread());
191 DCHECK(stream); 191 DCHECK(stream);
192 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO); 192 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO);
(...skipping 17 matching lines...) Expand all
210 error_cb_ = error_cb; 210 error_cb_ = error_cb;
211 211
212 decoder_selector_->SelectAudioDecoder( 212 decoder_selector_->SelectAudioDecoder(
213 stream, 213 stream,
214 statistics_cb, 214 statistics_cb,
215 base::Bind(&AudioRendererImpl::OnDecoderSelected, weak_this_)); 215 base::Bind(&AudioRendererImpl::OnDecoderSelected, weak_this_));
216 } 216 }
217 217
218 void AudioRendererImpl::OnDecoderSelected( 218 void AudioRendererImpl::OnDecoderSelected(
219 scoped_ptr<AudioDecoder> decoder, 219 scoped_ptr<AudioDecoder> decoder,
220 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream) { 220 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) {
221 DCHECK(message_loop_->BelongsToCurrentThread()); 221 DCHECK(message_loop_->BelongsToCurrentThread());
222 scoped_ptr<AudioDecoderSelector> deleter(decoder_selector_.Pass()); 222 scoped_ptr<AudioDecoderSelector> deleter(decoder_selector_.Pass());
223 223
224 if (state_ == kStopped) { 224 if (state_ == kStopped) {
225 DCHECK(!sink_); 225 DCHECK(!sink_);
226 return; 226 return;
227 } 227 }
228 228
229 if (!decoder) { 229 if (!decoder) {
230 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 230 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
231 return; 231 return;
232 } 232 }
233 233
234 decoder_ = decoder.Pass(); 234 decoder_ = decoder.Pass();
235 decrypting_demuxer_stream_ = decrypting_demuxer_stream; 235 decrypting_demuxer_stream_ = decrypting_demuxer_stream.Pass();
236 236
237 int sample_rate = decoder_->samples_per_second(); 237 int sample_rate = decoder_->samples_per_second();
238 int buffer_size = GetHighLatencyOutputBufferSize(sample_rate); 238 int buffer_size = GetHighLatencyOutputBufferSize(sample_rate);
239 AudioParameters::Format format = AudioParameters::AUDIO_PCM_LINEAR; 239 AudioParameters::Format format = AudioParameters::AUDIO_PCM_LINEAR;
240 240
241 // Either AudioOutputResampler or renderer side mixing must be enabled to use 241 // Either AudioOutputResampler or renderer side mixing must be enabled to use
242 // the low latency pipeline. 242 // the low latency pipeline.
243 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 243 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
244 if (!cmd_line->HasSwitch(switches::kDisableRendererSideMixing) || 244 if (!cmd_line->HasSwitch(switches::kDisableRendererSideMixing) ||
245 !cmd_line->HasSwitch(switches::kDisableAudioOutputResampler)) { 245 !cmd_line->HasSwitch(switches::kDisableAudioOutputResampler)) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 case kUnderflow: 657 case kUnderflow:
658 case kRebuffering: 658 case kRebuffering:
659 case kStopped: 659 case kStopped:
660 if (status != PIPELINE_OK) 660 if (status != PIPELINE_OK)
661 error_cb_.Run(status); 661 error_cb_.Run(status);
662 return; 662 return;
663 } 663 }
664 } 664 }
665 665
666 } // namespace media 666 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698