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

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

Issue 418143005: media: Introduce Renderer interface and RendererImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix media/BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DCHECK(!statistics_cb.is_null()); 248 DCHECK(!statistics_cb.is_null());
249 DCHECK(!time_cb.is_null()); 249 DCHECK(!time_cb.is_null());
250 DCHECK(!buffering_state_cb.is_null()); 250 DCHECK(!buffering_state_cb.is_null());
251 DCHECK(!ended_cb.is_null()); 251 DCHECK(!ended_cb.is_null());
252 DCHECK(!error_cb.is_null()); 252 DCHECK(!error_cb.is_null());
253 DCHECK_EQ(kUninitialized, state_); 253 DCHECK_EQ(kUninitialized, state_);
254 DCHECK(sink_); 254 DCHECK(sink_);
255 255
256 state_ = kInitializing; 256 state_ = kInitializing;
257 257
258 init_cb_ = init_cb; 258 // Always post |init_cb_| because |this| could be destroyed if initialization
259 // failed.
260 init_cb_ = BindToCurrentLoop(init_cb);
261
259 time_cb_ = time_cb; 262 time_cb_ = time_cb;
260 buffering_state_cb_ = buffering_state_cb; 263 buffering_state_cb_ = buffering_state_cb;
261 ended_cb_ = ended_cb; 264 ended_cb_ = ended_cb;
262 error_cb_ = error_cb; 265 error_cb_ = error_cb;
263 266
264 expecting_config_changes_ = stream->SupportsConfigChanges(); 267 expecting_config_changes_ = stream->SupportsConfigChanges();
265 if (!expecting_config_changes_) { 268 if (!expecting_config_changes_) {
266 // The actual buffer size is controlled via the size of the AudioBus 269 // The actual buffer size is controlled via the size of the AudioBus
267 // provided to Render(), so just choose something reasonable here for looks. 270 // provided to Render(), so just choose something reasonable here for looks.
268 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; 271 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 { 340 {
338 base::AutoUnlock auto_unlock(lock_); 341 base::AutoUnlock auto_unlock(lock_);
339 sink_->Initialize(audio_parameters_, this); 342 sink_->Initialize(audio_parameters_, this);
340 sink_->Start(); 343 sink_->Start();
341 344
342 // Some sinks play on start... 345 // Some sinks play on start...
343 sink_->Pause(); 346 sink_->Pause();
344 } 347 }
345 348
346 DCHECK(!sink_playing_); 349 DCHECK(!sink_playing_);
347
348 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); 350 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
349 } 351 }
350 352
351 void AudioRendererImpl::SetVolume(float volume) { 353 void AudioRendererImpl::SetVolume(float volume) {
352 DCHECK(task_runner_->BelongsToCurrentThread()); 354 DCHECK(task_runner_->BelongsToCurrentThread());
353 DCHECK(sink_); 355 DCHECK(sink_);
354 sink_->SetVolume(volume); 356 sink_->SetVolume(volume);
355 } 357 }
356 358
357 void AudioRendererImpl::DecodedAudioReady( 359 void AudioRendererImpl::DecodedAudioReady(
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 << buffering_state; 695 << buffering_state;
694 DCHECK_NE(buffering_state_, buffering_state); 696 DCHECK_NE(buffering_state_, buffering_state);
695 lock_.AssertAcquired(); 697 lock_.AssertAcquired();
696 buffering_state_ = buffering_state; 698 buffering_state_ = buffering_state;
697 699
698 task_runner_->PostTask(FROM_HERE, 700 task_runner_->PostTask(FROM_HERE,
699 base::Bind(buffering_state_cb_, buffering_state_)); 701 base::Bind(buffering_state_cb_, buffering_state_));
700 } 702 }
701 703
702 } // namespace media 704 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698