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

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

Issue 518613002: Have AudioRendererImpl advance time until it's told to stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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_renderer_impl.cc ('k') | media/filters/renderer_impl_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer_impl.h" 5 #include "media/filters/renderer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void RendererImpl::OnAudioRendererEnded() { 494 void RendererImpl::OnAudioRendererEnded() {
495 DVLOG(1) << __FUNCTION__; 495 DVLOG(1) << __FUNCTION__;
496 DCHECK(task_runner_->BelongsToCurrentThread()); 496 DCHECK(task_runner_->BelongsToCurrentThread());
497 497
498 if (state_ != STATE_PLAYING) 498 if (state_ != STATE_PLAYING)
499 return; 499 return;
500 500
501 DCHECK(!audio_ended_); 501 DCHECK(!audio_ended_);
502 audio_ended_ = true; 502 audio_ended_ = true;
503 503
504 // Start clock since there is no more audio to trigger clock updates.
505 {
506 base::TimeDelta duration = get_duration_cb_.Run();
507 base::AutoLock auto_lock(interpolator_lock_);
508 interpolator_->SetUpperBound(duration);
509 StartClockIfWaitingForTimeUpdate_Locked();
510 }
511
512 RunEndedCallbackIfNeeded(); 504 RunEndedCallbackIfNeeded();
513 } 505 }
514 506
515 void RendererImpl::OnVideoRendererEnded() { 507 void RendererImpl::OnVideoRendererEnded() {
516 DVLOG(1) << __FUNCTION__; 508 DVLOG(1) << __FUNCTION__;
517 DCHECK(task_runner_->BelongsToCurrentThread()); 509 DCHECK(task_runner_->BelongsToCurrentThread());
518 510
519 if (state_ != STATE_PLAYING) 511 if (state_ != STATE_PLAYING)
520 return; 512 return;
521 513
522 DCHECK(!video_ended_); 514 DCHECK(!video_ended_);
523 video_ended_ = true; 515 video_ended_ = true;
524 516
525 RunEndedCallbackIfNeeded(); 517 RunEndedCallbackIfNeeded();
526 } 518 }
527 519
528 void RendererImpl::RunEndedCallbackIfNeeded() { 520 void RendererImpl::RunEndedCallbackIfNeeded() {
529 DVLOG(1) << __FUNCTION__; 521 DVLOG(1) << __FUNCTION__;
530 DCHECK(task_runner_->BelongsToCurrentThread()); 522 DCHECK(task_runner_->BelongsToCurrentThread());
531 523
532 if (audio_renderer_ && !audio_ended_) 524 if (audio_renderer_ && !audio_ended_)
533 return; 525 return;
534 526
535 if (video_renderer_ && !video_ended_) 527 if (video_renderer_ && !video_ended_)
536 return; 528 return;
537 529
538 { 530 {
539 base::TimeDelta duration = get_duration_cb_.Run();
540 base::AutoLock auto_lock(interpolator_lock_); 531 base::AutoLock auto_lock(interpolator_lock_);
541 PauseClockAndStopTicking_Locked(); 532 PauseClockAndStopTicking_Locked();
542 interpolator_->SetBounds(duration, duration);
543 } 533 }
544 534
545 ended_cb_.Run(); 535 ended_cb_.Run();
546 } 536 }
547 537
548 void RendererImpl::OnError(PipelineStatus error) { 538 void RendererImpl::OnError(PipelineStatus error) {
549 DVLOG(1) << __FUNCTION__ << "(" << error << ")"; 539 DVLOG(1) << __FUNCTION__ << "(" << error << ")";
550 DCHECK(task_runner_->BelongsToCurrentThread()); 540 DCHECK(task_runner_->BelongsToCurrentThread());
551 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!"; 541 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!";
552 542
553 state_ = STATE_ERROR; 543 state_ = STATE_ERROR;
554 544
555 // Pipeline will destroy |this| as the result of error. 545 // Pipeline will destroy |this| as the result of error.
556 base::ResetAndReturn(&error_cb_).Run(error); 546 base::ResetAndReturn(&error_cb_).Run(error);
557 547
558 FireAllPendingCallbacks(); 548 FireAllPendingCallbacks();
559 } 549 }
560 550
561 void RendererImpl::FireAllPendingCallbacks() { 551 void RendererImpl::FireAllPendingCallbacks() {
562 DCHECK(task_runner_->BelongsToCurrentThread()); 552 DCHECK(task_runner_->BelongsToCurrentThread());
563 553
564 if (!init_cb_.is_null()) 554 if (!init_cb_.is_null())
565 base::ResetAndReturn(&init_cb_).Run(); 555 base::ResetAndReturn(&init_cb_).Run();
566 556
567 if (!flush_cb_.is_null()) 557 if (!flush_cb_.is_null())
568 base::ResetAndReturn(&flush_cb_).Run(); 558 base::ResetAndReturn(&flush_cb_).Run();
569 } 559 }
570 560
571 } // namespace media 561 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_renderer_impl.cc ('k') | media/filters/renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698