| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |