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

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

Issue 506683002: Remove implicit conversions from scoped_refptr to T* in media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 DCHECK(task_runner_->BelongsToCurrentThread()); 247 DCHECK(task_runner_->BelongsToCurrentThread());
248 DCHECK(stream); 248 DCHECK(stream);
249 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO); 249 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO);
250 DCHECK(!init_cb.is_null()); 250 DCHECK(!init_cb.is_null());
251 DCHECK(!statistics_cb.is_null()); 251 DCHECK(!statistics_cb.is_null());
252 DCHECK(!time_cb.is_null()); 252 DCHECK(!time_cb.is_null());
253 DCHECK(!buffering_state_cb.is_null()); 253 DCHECK(!buffering_state_cb.is_null());
254 DCHECK(!ended_cb.is_null()); 254 DCHECK(!ended_cb.is_null());
255 DCHECK(!error_cb.is_null()); 255 DCHECK(!error_cb.is_null());
256 DCHECK_EQ(kUninitialized, state_); 256 DCHECK_EQ(kUninitialized, state_);
257 DCHECK(sink_); 257 DCHECK(sink_.get());
258 258
259 state_ = kInitializing; 259 state_ = kInitializing;
260 260
261 // Always post |init_cb_| because |this| could be destroyed if initialization 261 // Always post |init_cb_| because |this| could be destroyed if initialization
262 // failed. 262 // failed.
263 init_cb_ = BindToCurrentLoop(init_cb); 263 init_cb_ = BindToCurrentLoop(init_cb);
264 264
265 time_cb_ = time_cb; 265 time_cb_ = time_cb;
266 buffering_state_cb_ = buffering_state_cb; 266 buffering_state_cb_ = buffering_state_cb;
267 ended_cb_ = ended_cb; 267 ended_cb_ = ended_cb;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Some sinks play on start... 349 // Some sinks play on start...
350 sink_->Pause(); 350 sink_->Pause();
351 } 351 }
352 352
353 DCHECK(!sink_playing_); 353 DCHECK(!sink_playing_);
354 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); 354 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
355 } 355 }
356 356
357 void AudioRendererImpl::SetVolume(float volume) { 357 void AudioRendererImpl::SetVolume(float volume) {
358 DCHECK(task_runner_->BelongsToCurrentThread()); 358 DCHECK(task_runner_->BelongsToCurrentThread());
359 DCHECK(sink_); 359 DCHECK(sink_.get());
360 sink_->SetVolume(volume); 360 sink_->SetVolume(volume);
361 } 361 }
362 362
363 void AudioRendererImpl::DecodedAudioReady( 363 void AudioRendererImpl::DecodedAudioReady(
364 AudioBufferStream::Status status, 364 AudioBufferStream::Status status,
365 const scoped_refptr<AudioBuffer>& buffer) { 365 const scoped_refptr<AudioBuffer>& buffer) {
366 DVLOG(2) << __FUNCTION__ << "(" << status << ")"; 366 DVLOG(2) << __FUNCTION__ << "(" << status << ")";
367 DCHECK(task_runner_->BelongsToCurrentThread()); 367 DCHECK(task_runner_->BelongsToCurrentThread());
368 368
369 base::AutoLock auto_lock(lock_); 369 base::AutoLock auto_lock(lock_);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 503 }
504 504
505 return !pending_read_ && !received_end_of_stream_ && 505 return !pending_read_ && !received_end_of_stream_ &&
506 !algorithm_->IsQueueFull(); 506 !algorithm_->IsQueueFull();
507 } 507 }
508 508
509 void AudioRendererImpl::SetPlaybackRate(float playback_rate) { 509 void AudioRendererImpl::SetPlaybackRate(float playback_rate) {
510 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")"; 510 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")";
511 DCHECK(task_runner_->BelongsToCurrentThread()); 511 DCHECK(task_runner_->BelongsToCurrentThread());
512 DCHECK_GE(playback_rate, 0); 512 DCHECK_GE(playback_rate, 0);
513 DCHECK(sink_); 513 DCHECK(sink_.get());
514 514
515 base::AutoLock auto_lock(lock_); 515 base::AutoLock auto_lock(lock_);
516 516
517 // We have two cases here: 517 // We have two cases here:
518 // Play: current_playback_rate == 0 && playback_rate != 0 518 // Play: current_playback_rate == 0 && playback_rate != 0
519 // Pause: current_playback_rate != 0 && playback_rate == 0 519 // Pause: current_playback_rate != 0 && playback_rate == 0
520 float current_playback_rate = playback_rate_; 520 float current_playback_rate = playback_rate_;
521 playback_rate_ = playback_rate; 521 playback_rate_ = playback_rate;
522 522
523 if (!rendering_) 523 if (!rendering_)
524 return; 524 return;
525 525
526 if (current_playback_rate == 0 && playback_rate != 0) { 526 if (current_playback_rate == 0 && playback_rate != 0) {
527 StartRendering_Locked(); 527 StartRendering_Locked();
528 return; 528 return;
529 } 529 }
530 530
531 if (current_playback_rate != 0 && playback_rate == 0) { 531 if (current_playback_rate != 0 && playback_rate == 0) {
532 StopRendering_Locked(); 532 StopRendering_Locked();
533 return; 533 return;
534 } 534 }
535 } 535 }
536 536
537 bool AudioRendererImpl::IsBeforeStartTime( 537 bool AudioRendererImpl::IsBeforeStartTime(
538 const scoped_refptr<AudioBuffer>& buffer) { 538 const scoped_refptr<AudioBuffer>& buffer) {
539 DCHECK_EQ(state_, kPlaying); 539 DCHECK_EQ(state_, kPlaying);
540 return buffer && !buffer->end_of_stream() && 540 return buffer.get() && !buffer->end_of_stream() &&
541 (buffer->timestamp() + buffer->duration()) < start_timestamp_; 541 (buffer->timestamp() + buffer->duration()) < start_timestamp_;
542 } 542 }
543 543
544 int AudioRendererImpl::Render(AudioBus* audio_bus, 544 int AudioRendererImpl::Render(AudioBus* audio_bus,
545 int audio_delay_milliseconds) { 545 int audio_delay_milliseconds) {
546 const int requested_frames = audio_bus->frames(); 546 const int requested_frames = audio_bus->frames();
547 base::TimeDelta playback_delay = base::TimeDelta::FromMilliseconds( 547 base::TimeDelta playback_delay = base::TimeDelta::FromMilliseconds(
548 audio_delay_milliseconds); 548 audio_delay_milliseconds);
549 const int delay_frames = static_cast<int>(playback_delay.InSecondsF() * 549 const int delay_frames = static_cast<int>(playback_delay.InSecondsF() *
550 audio_parameters_.sample_rate()); 550 audio_parameters_.sample_rate());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 << buffering_state; 701 << buffering_state;
702 DCHECK_NE(buffering_state_, buffering_state); 702 DCHECK_NE(buffering_state_, buffering_state);
703 lock_.AssertAcquired(); 703 lock_.AssertAcquired();
704 buffering_state_ = buffering_state; 704 buffering_state_ = buffering_state;
705 705
706 task_runner_->PostTask(FROM_HERE, 706 task_runner_->PostTask(FROM_HERE,
707 base::Bind(buffering_state_cb_, buffering_state_)); 707 base::Bind(buffering_state_cb_, buffering_state_));
708 } 708 }
709 709
710 } // namespace media 710 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698