OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, | 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, |
6 // potential deadlocks, etc... | 6 // potential deadlocks, etc... |
7 | 7 |
8 #include "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 | 212 |
213 base::AutoLock auto_lock(lock_); | 213 base::AutoLock auto_lock(lock_); |
214 volume_ = volume; | 214 volume_ = volume; |
215 if (running_) { | 215 if (running_) { |
216 message_loop_->PostTask(FROM_HERE, | 216 message_loop_->PostTask(FROM_HERE, |
217 NewRunnableMethod(this, &PipelineImpl::VolumeChangedTask, | 217 NewRunnableMethod(this, &PipelineImpl::VolumeChangedTask, |
218 volume)); | 218 volume)); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 Preload PipelineImpl::GetPreload() const { | |
223 base::AutoLock auto_lock(lock_); | |
224 return preload_; | |
225 } | |
226 | |
227 void PipelineImpl::SetPreload(Preload preload) { | |
228 base::AutoLock auto_lock(lock_); | |
229 preload_ = preload; | |
230 if (running_) { | |
231 message_loop_->PostTask(FROM_HERE, | |
232 NewRunnableMethod(this, &PipelineImpl::PreloadChangedTask, | |
233 preload)); | |
234 } | |
235 } | |
236 | |
222 base::TimeDelta PipelineImpl::GetCurrentTime() const { | 237 base::TimeDelta PipelineImpl::GetCurrentTime() const { |
223 // TODO(scherkus): perhaps replace checking state_ == kEnded with a bool that | 238 // TODO(scherkus): perhaps replace checking state_ == kEnded with a bool that |
224 // is set/get under the lock, because this is breaching the contract that | 239 // is set/get under the lock, because this is breaching the contract that |
225 // |state_| is only accessed on |message_loop_|. | 240 // |state_| is only accessed on |message_loop_|. |
226 base::AutoLock auto_lock(lock_); | 241 base::AutoLock auto_lock(lock_); |
227 return GetCurrentTime_Locked(); | 242 return GetCurrentTime_Locked(); |
228 } | 243 } |
229 | 244 |
230 base::TimeDelta PipelineImpl::GetCurrentTime_Locked() const { | 245 base::TimeDelta PipelineImpl::GetCurrentTime_Locked() const { |
231 base::TimeDelta elapsed = clock_->Elapsed(); | 246 base::TimeDelta elapsed = clock_->Elapsed(); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 pipeline_init_state_.reset(); | 693 pipeline_init_state_.reset(); |
679 | 694 |
680 if (audio_disabled_) { | 695 if (audio_disabled_) { |
681 // Audio was disabled at some point during initialization. Notify | 696 // Audio was disabled at some point during initialization. Notify |
682 // the pipeline filter now that it has been initialized. | 697 // the pipeline filter now that it has been initialized. |
683 pipeline_filter_->OnAudioRendererDisabled(); | 698 pipeline_filter_->OnAudioRendererDisabled(); |
684 } | 699 } |
685 | 700 |
686 // Initialization was successful, we are now considered paused, so it's safe | 701 // Initialization was successful, we are now considered paused, so it's safe |
687 // to set the initial playback rate and volume. | 702 // to set the initial playback rate and volume. |
703 PreloadChangedTask(GetPreload()); | |
688 PlaybackRateChangedTask(GetPlaybackRate()); | 704 PlaybackRateChangedTask(GetPlaybackRate()); |
689 VolumeChangedTask(GetVolume()); | 705 VolumeChangedTask(GetVolume()); |
690 | 706 |
691 // Fire the seek request to get the filters to preroll. | 707 // Fire the seek request to get the filters to preroll. |
692 seek_pending_ = true; | 708 seek_pending_ = true; |
693 set_state(kSeeking); | 709 set_state(kSeeking); |
694 seek_timestamp_ = base::TimeDelta(); | 710 seek_timestamp_ = base::TimeDelta(); |
695 pipeline_filter_->Seek(seek_timestamp_, | 711 pipeline_filter_->Seek(seek_timestamp_, |
696 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); | 712 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); |
697 } | 713 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 } | 794 } |
779 | 795 |
780 void PipelineImpl::VolumeChangedTask(float volume) { | 796 void PipelineImpl::VolumeChangedTask(float volume) { |
781 DCHECK_EQ(MessageLoop::current(), message_loop_); | 797 DCHECK_EQ(MessageLoop::current(), message_loop_); |
782 | 798 |
783 if (audio_renderer_) { | 799 if (audio_renderer_) { |
784 audio_renderer_->SetVolume(volume); | 800 audio_renderer_->SetVolume(volume); |
785 } | 801 } |
786 } | 802 } |
787 | 803 |
804 void PipelineImpl::PreloadChangedTask(Preload preload) { | |
805 DCHECK_EQ(MessageLoop::current(), message_loop_); | |
806 if (demuxer_) | |
807 demuxer_->SetPreload(preload); | |
808 } | |
809 | |
788 void PipelineImpl::SeekTask(base::TimeDelta time, | 810 void PipelineImpl::SeekTask(base::TimeDelta time, |
789 PipelineStatusCallback* seek_callback) { | 811 PipelineStatusCallback* seek_callback) { |
790 DCHECK_EQ(MessageLoop::current(), message_loop_); | 812 DCHECK_EQ(MessageLoop::current(), message_loop_); |
791 DCHECK(!IsPipelineStopPending()); | 813 DCHECK(!IsPipelineStopPending()); |
792 | 814 |
793 // Suppress seeking if we're not fully started. | 815 // Suppress seeking if we're not fully started. |
794 if (state_ != kStarted && state_ != kEnded) { | 816 if (state_ != kStarted && state_ != kEnded) { |
795 // TODO(scherkus): should we run the callback? I'm tempted to say the API | 817 // TODO(scherkus): should we run the callback? I'm tempted to say the API |
796 // will only execute the first Seek() request. | 818 // will only execute the first Seek() request. |
797 VLOG(1) << "Media pipeline has not started, ignoring seek to " | 819 VLOG(1) << "Media pipeline has not started, ignoring seek to " |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 break; | 1009 break; |
988 // default: intentionally left out to force new states to cause compiler | 1010 // default: intentionally left out to force new states to cause compiler |
989 // errors. | 1011 // errors. |
990 }; | 1012 }; |
991 } | 1013 } |
992 | 1014 |
993 void PipelineImpl::FinishDestroyingFiltersTask() { | 1015 void PipelineImpl::FinishDestroyingFiltersTask() { |
994 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1016 DCHECK_EQ(MessageLoop::current(), message_loop_); |
995 DCHECK(IsPipelineStopped()); | 1017 DCHECK(IsPipelineStopped()); |
996 | 1018 |
997 // Clear renderer references. | 1019 // Clear filter references. |
998 audio_renderer_ = NULL; | 1020 audio_renderer_ = NULL; |
999 video_renderer_ = NULL; | 1021 video_renderer_ = NULL; |
1022 demuxer_ = NULL; | |
1000 | 1023 |
1001 pipeline_filter_ = NULL; | 1024 pipeline_filter_ = NULL; |
1002 | 1025 |
1003 if (error_caused_teardown_ && !IsPipelineOk() && error_callback_.get()) | 1026 if (error_caused_teardown_ && !IsPipelineOk() && error_callback_.get()) |
1004 error_callback_->Run(status_); | 1027 error_callback_->Run(status_); |
1005 | 1028 |
1006 if (stop_pending_) { | 1029 if (stop_pending_) { |
1007 stop_pending_ = false; | 1030 stop_pending_ = false; |
1008 ResetState(); | 1031 ResetState(); |
1009 scoped_ptr<PipelineStatusCallback> stop_callback(stop_callback_.release()); | 1032 scoped_ptr<PipelineStatusCallback> stop_callback(stop_callback_.release()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 } | 1073 } |
1051 | 1074 |
1052 if (!demuxer) { | 1075 if (!demuxer) { |
1053 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 1076 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
1054 return; | 1077 return; |
1055 } | 1078 } |
1056 | 1079 |
1057 if (!PrepareFilter(demuxer)) | 1080 if (!PrepareFilter(demuxer)) |
1058 return; | 1081 return; |
1059 | 1082 |
1060 pipeline_init_state_->demuxer_ = demuxer; | 1083 pipeline_init_state_->demuxer_ = demuxer; |
acolwell GONE FROM CHROMIUM
2011/03/25 04:35:28
Remove demuxer_ from pipeline_init_state since Pip
vrk (LEFT CHROMIUM)
2011/03/25 21:33:32
Done.
| |
1084 demuxer_ = demuxer; | |
1061 OnFilterInitialize(); | 1085 OnFilterInitialize(); |
1062 } | 1086 } |
1063 | 1087 |
1064 bool PipelineImpl::InitializeAudioDecoder( | 1088 bool PipelineImpl::InitializeAudioDecoder( |
1065 const scoped_refptr<Demuxer>& demuxer) { | 1089 const scoped_refptr<Demuxer>& demuxer) { |
1066 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1090 DCHECK_EQ(MessageLoop::current(), message_loop_); |
1067 DCHECK(IsPipelineOk()); | 1091 DCHECK(IsPipelineOk()); |
1068 | 1092 |
1069 scoped_refptr<DemuxerStream> stream = | 1093 scoped_refptr<DemuxerStream> stream = |
1070 demuxer->GetStream(DemuxerStream::AUDIO); | 1094 demuxer->GetStream(DemuxerStream::AUDIO); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 case kStopping: | 1257 case kStopping: |
1234 case kStopped: | 1258 case kStopped: |
1235 NOTREACHED() << "Unexpected state for teardown: " << state_; | 1259 NOTREACHED() << "Unexpected state for teardown: " << state_; |
1236 break; | 1260 break; |
1237 // default: intentionally left out to force new states to cause compiler | 1261 // default: intentionally left out to force new states to cause compiler |
1238 // errors. | 1262 // errors. |
1239 }; | 1263 }; |
1240 } | 1264 } |
1241 | 1265 |
1242 } // namespace media | 1266 } // namespace media |
OLD | NEW |