OLD | NEW |
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/base/pipeline.h" | 5 #include "media/base/pipeline.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 #endif | 440 #endif |
441 | 441 |
442 void Pipeline::DoSeek( | 442 void Pipeline::DoSeek( |
443 base::TimeDelta seek_timestamp, | 443 base::TimeDelta seek_timestamp, |
444 const PipelineStatusCB& done_cb) { | 444 const PipelineStatusCB& done_cb) { |
445 DCHECK(task_runner_->BelongsToCurrentThread()); | 445 DCHECK(task_runner_->BelongsToCurrentThread()); |
446 DCHECK(!pending_callbacks_.get()); | 446 DCHECK(!pending_callbacks_.get()); |
447 SerialRunner::Queue bound_fns; | 447 SerialRunner::Queue bound_fns; |
448 { | 448 { |
449 base::AutoLock auto_lock(lock_); | 449 base::AutoLock auto_lock(lock_); |
450 PauseClockAndStopRendering_Locked(); | 450 PauseClockAndStopTicking_Locked(); |
451 } | 451 } |
452 | 452 |
453 // Pause. | 453 // Pause. |
454 if (text_renderer_) { | 454 if (text_renderer_) { |
455 bound_fns.Push(base::Bind( | 455 bound_fns.Push(base::Bind( |
456 &TextRenderer::Pause, base::Unretained(text_renderer_.get()))); | 456 &TextRenderer::Pause, base::Unretained(text_renderer_.get()))); |
457 } | 457 } |
458 | 458 |
459 // Flush. | 459 // Flush. |
460 if (audio_renderer_) { | 460 if (audio_renderer_) { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return; | 743 return; |
744 | 744 |
745 if (video_renderer_ && !video_ended_) | 745 if (video_renderer_ && !video_ended_) |
746 return; | 746 return; |
747 | 747 |
748 if (text_renderer_ && text_renderer_->HasTracks() && !text_ended_) | 748 if (text_renderer_ && text_renderer_->HasTracks() && !text_ended_) |
749 return; | 749 return; |
750 | 750 |
751 { | 751 { |
752 base::AutoLock auto_lock(lock_); | 752 base::AutoLock auto_lock(lock_); |
753 PauseClockAndStopRendering_Locked(); | 753 PauseClockAndStopTicking_Locked(); |
754 interpolator_->SetBounds(duration_, duration_); | 754 interpolator_->SetBounds(duration_, duration_); |
755 } | 755 } |
756 | 756 |
757 DCHECK_EQ(status_, PIPELINE_OK); | 757 DCHECK_EQ(status_, PIPELINE_OK); |
758 ended_cb_.Run(); | 758 ended_cb_.Run(); |
759 } | 759 } |
760 | 760 |
761 void Pipeline::AddTextStreamTask(DemuxerStream* text_stream, | 761 void Pipeline::AddTextStreamTask(DemuxerStream* text_stream, |
762 const TextTrackConfig& config) { | 762 const TextTrackConfig& config) { |
763 DCHECK(task_runner_->BelongsToCurrentThread()); | 763 DCHECK(task_runner_->BelongsToCurrentThread()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 return false; | 856 return false; |
857 } | 857 } |
858 | 858 |
859 void Pipeline::PausePlayback() { | 859 void Pipeline::PausePlayback() { |
860 DVLOG(1) << __FUNCTION__; | 860 DVLOG(1) << __FUNCTION__; |
861 DCHECK_EQ(state_, kPlaying); | 861 DCHECK_EQ(state_, kPlaying); |
862 DCHECK(WaitingForEnoughData()); | 862 DCHECK(WaitingForEnoughData()); |
863 DCHECK(task_runner_->BelongsToCurrentThread()); | 863 DCHECK(task_runner_->BelongsToCurrentThread()); |
864 | 864 |
865 base::AutoLock auto_lock(lock_); | 865 base::AutoLock auto_lock(lock_); |
866 PauseClockAndStopRendering_Locked(); | 866 PauseClockAndStopTicking_Locked(); |
867 } | 867 } |
868 | 868 |
869 void Pipeline::StartPlayback() { | 869 void Pipeline::StartPlayback() { |
870 DVLOG(1) << __FUNCTION__; | 870 DVLOG(1) << __FUNCTION__; |
871 DCHECK_EQ(state_, kPlaying); | 871 DCHECK_EQ(state_, kPlaying); |
872 DCHECK_EQ(interpolation_state_, INTERPOLATION_STOPPED); | 872 DCHECK_EQ(interpolation_state_, INTERPOLATION_STOPPED); |
873 DCHECK(!WaitingForEnoughData()); | 873 DCHECK(!WaitingForEnoughData()); |
874 DCHECK(task_runner_->BelongsToCurrentThread()); | 874 DCHECK(task_runner_->BelongsToCurrentThread()); |
875 | 875 |
876 if (audio_renderer_) { | 876 if (audio_renderer_) { |
877 // We use audio stream to update the clock. So if there is such a | 877 // We use audio stream to update the clock. So if there is such a |
878 // stream, we pause the clock until we receive a valid timestamp. | 878 // stream, we pause the clock until we receive a valid timestamp. |
879 base::AutoLock auto_lock(lock_); | 879 base::AutoLock auto_lock(lock_); |
880 interpolation_state_ = INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE; | 880 interpolation_state_ = INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE; |
881 audio_renderer_->StartRendering(); | 881 audio_renderer_->StartTicking(); |
882 } else { | 882 } else { |
883 base::AutoLock auto_lock(lock_); | 883 base::AutoLock auto_lock(lock_); |
884 interpolation_state_ = INTERPOLATION_STARTED; | 884 interpolation_state_ = INTERPOLATION_STARTED; |
885 interpolator_->SetUpperBound(duration_); | 885 interpolator_->SetUpperBound(duration_); |
886 interpolator_->StartInterpolating(); | 886 interpolator_->StartInterpolating(); |
887 } | 887 } |
888 } | 888 } |
889 | 889 |
890 void Pipeline::PauseClockAndStopRendering_Locked() { | 890 void Pipeline::PauseClockAndStopTicking_Locked() { |
891 lock_.AssertAcquired(); | 891 lock_.AssertAcquired(); |
892 switch (interpolation_state_) { | 892 switch (interpolation_state_) { |
893 case INTERPOLATION_STOPPED: | 893 case INTERPOLATION_STOPPED: |
894 return; | 894 return; |
895 | 895 |
896 case INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE: | 896 case INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE: |
897 audio_renderer_->StopRendering(); | 897 audio_renderer_->StopTicking(); |
898 break; | 898 break; |
899 | 899 |
900 case INTERPOLATION_STARTED: | 900 case INTERPOLATION_STARTED: |
901 if (audio_renderer_) | 901 if (audio_renderer_) |
902 audio_renderer_->StopRendering(); | 902 audio_renderer_->StopTicking(); |
903 interpolator_->StopInterpolating(); | 903 interpolator_->StopInterpolating(); |
904 break; | 904 break; |
905 } | 905 } |
906 | 906 |
907 interpolation_state_ = INTERPOLATION_STOPPED; | 907 interpolation_state_ = INTERPOLATION_STOPPED; |
908 } | 908 } |
909 | 909 |
910 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 910 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
911 lock_.AssertAcquired(); | 911 lock_.AssertAcquired(); |
912 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) | 912 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) |
913 return; | 913 return; |
914 | 914 |
915 interpolation_state_ = INTERPOLATION_STARTED; | 915 interpolation_state_ = INTERPOLATION_STARTED; |
916 interpolator_->StartInterpolating(); | 916 interpolator_->StartInterpolating(); |
917 } | 917 } |
918 | 918 |
919 } // namespace media | 919 } // namespace media |
OLD | NEW |