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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 DCHECK_EQ(interpolation_state_, INTERPOLATION_STOPPED); | 449 DCHECK_EQ(interpolation_state_, INTERPOLATION_STOPPED); |
450 DCHECK(!WaitingForEnoughData()); | 450 DCHECK(!WaitingForEnoughData()); |
451 | 451 |
452 if (time_source_) { | 452 if (time_source_) { |
453 // We use audio stream to update the interpolator. So if there is such a | 453 // We use audio stream to update the interpolator. So if there is such a |
454 // stream, we pause the interpolator until we receive a valid time update. | 454 // stream, we pause the interpolator until we receive a valid time update. |
455 base::AutoLock auto_lock(interpolator_lock_); | 455 base::AutoLock auto_lock(interpolator_lock_); |
456 interpolation_state_ = INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE; | 456 interpolation_state_ = INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE; |
457 time_source_->StartTicking(); | 457 time_source_->StartTicking(); |
458 } else { | 458 } else { |
| 459 base::TimeDelta duration = get_duration_cb_.Run(); |
459 base::AutoLock auto_lock(interpolator_lock_); | 460 base::AutoLock auto_lock(interpolator_lock_); |
460 interpolation_state_ = INTERPOLATION_STARTED; | 461 interpolation_state_ = INTERPOLATION_STARTED; |
461 interpolator_->SetUpperBound(get_duration_cb_.Run()); | 462 interpolator_->SetUpperBound(duration); |
462 interpolator_->StartInterpolating(); | 463 interpolator_->StartInterpolating(); |
463 } | 464 } |
464 } | 465 } |
465 | 466 |
466 void RendererImpl::PauseClockAndStopTicking_Locked() { | 467 void RendererImpl::PauseClockAndStopTicking_Locked() { |
467 DVLOG(2) << __FUNCTION__; | 468 DVLOG(2) << __FUNCTION__; |
468 interpolator_lock_.AssertAcquired(); | 469 interpolator_lock_.AssertAcquired(); |
469 switch (interpolation_state_) { | 470 switch (interpolation_state_) { |
470 case INTERPOLATION_STOPPED: | 471 case INTERPOLATION_STOPPED: |
471 return; | 472 return; |
(...skipping 26 matching lines...) Expand all Loading... |
498 DCHECK(task_runner_->BelongsToCurrentThread()); | 499 DCHECK(task_runner_->BelongsToCurrentThread()); |
499 | 500 |
500 if (state_ != STATE_PLAYING) | 501 if (state_ != STATE_PLAYING) |
501 return; | 502 return; |
502 | 503 |
503 DCHECK(!audio_ended_); | 504 DCHECK(!audio_ended_); |
504 audio_ended_ = true; | 505 audio_ended_ = true; |
505 | 506 |
506 // Start clock since there is no more audio to trigger clock updates. | 507 // Start clock since there is no more audio to trigger clock updates. |
507 { | 508 { |
| 509 base::TimeDelta duration = get_duration_cb_.Run(); |
508 base::AutoLock auto_lock(interpolator_lock_); | 510 base::AutoLock auto_lock(interpolator_lock_); |
509 interpolator_->SetUpperBound(get_duration_cb_.Run()); | 511 interpolator_->SetUpperBound(duration); |
510 StartClockIfWaitingForTimeUpdate_Locked(); | 512 StartClockIfWaitingForTimeUpdate_Locked(); |
511 } | 513 } |
512 | 514 |
513 RunEndedCallbackIfNeeded(); | 515 RunEndedCallbackIfNeeded(); |
514 } | 516 } |
515 | 517 |
516 void RendererImpl::OnVideoRendererEnded() { | 518 void RendererImpl::OnVideoRendererEnded() { |
517 DVLOG(2) << __FUNCTION__; | 519 DVLOG(2) << __FUNCTION__; |
518 DCHECK(task_runner_->BelongsToCurrentThread()); | 520 DCHECK(task_runner_->BelongsToCurrentThread()); |
519 | 521 |
(...skipping 10 matching lines...) Expand all Loading... |
530 DVLOG(2) << __FUNCTION__; | 532 DVLOG(2) << __FUNCTION__; |
531 DCHECK(task_runner_->BelongsToCurrentThread()); | 533 DCHECK(task_runner_->BelongsToCurrentThread()); |
532 | 534 |
533 if (audio_renderer_ && !audio_ended_) | 535 if (audio_renderer_ && !audio_ended_) |
534 return; | 536 return; |
535 | 537 |
536 if (video_renderer_ && !video_ended_) | 538 if (video_renderer_ && !video_ended_) |
537 return; | 539 return; |
538 | 540 |
539 { | 541 { |
| 542 base::TimeDelta duration = get_duration_cb_.Run(); |
540 base::AutoLock auto_lock(interpolator_lock_); | 543 base::AutoLock auto_lock(interpolator_lock_); |
541 PauseClockAndStopTicking_Locked(); | 544 PauseClockAndStopTicking_Locked(); |
542 base::TimeDelta duration = get_duration_cb_.Run(); | |
543 interpolator_->SetBounds(duration, duration); | 545 interpolator_->SetBounds(duration, duration); |
544 } | 546 } |
545 | 547 |
546 ended_cb_.Run(); | 548 ended_cb_.Run(); |
547 } | 549 } |
548 | 550 |
549 void RendererImpl::OnError(PipelineStatus error) { | 551 void RendererImpl::OnError(PipelineStatus error) { |
550 DVLOG(2) << __FUNCTION__; | 552 DVLOG(2) << __FUNCTION__; |
551 DCHECK(task_runner_->BelongsToCurrentThread()); | 553 DCHECK(task_runner_->BelongsToCurrentThread()); |
552 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!"; | 554 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!"; |
(...skipping 10 matching lines...) Expand all Loading... |
563 DCHECK(task_runner_->BelongsToCurrentThread()); | 565 DCHECK(task_runner_->BelongsToCurrentThread()); |
564 | 566 |
565 if (!init_cb_.is_null()) | 567 if (!init_cb_.is_null()) |
566 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); | 568 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); |
567 | 569 |
568 if (!flush_cb_.is_null()) | 570 if (!flush_cb_.is_null()) |
569 base::ResetAndReturn(&flush_cb_).Run(); | 571 base::ResetAndReturn(&flush_cb_).Run(); |
570 } | 572 } |
571 | 573 |
572 } // namespace media | 574 } // namespace media |
OLD | NEW |