Chromium Code Reviews| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 } | 351 } |
| 352 | 352 |
| 353 void PipelineImpl::ResetState() { | 353 void PipelineImpl::ResetState() { |
| 354 base::AutoLock auto_lock(lock_); | 354 base::AutoLock auto_lock(lock_); |
| 355 const base::TimeDelta kZero; | 355 const base::TimeDelta kZero; |
| 356 running_ = false; | 356 running_ = false; |
| 357 stop_pending_ = false; | 357 stop_pending_ = false; |
| 358 seek_pending_ = false; | 358 seek_pending_ = false; |
| 359 tearing_down_ = false; | 359 tearing_down_ = false; |
| 360 error_caused_teardown_ = false; | 360 error_caused_teardown_ = false; |
| 361 playback_rate_change_pending_ = false; | |
| 361 duration_ = kZero; | 362 duration_ = kZero; |
| 362 buffered_time_ = kZero; | 363 buffered_time_ = kZero; |
| 363 buffered_bytes_ = 0; | 364 buffered_bytes_ = 0; |
| 364 streaming_ = false; | 365 streaming_ = false; |
| 365 loaded_ = false; | 366 loaded_ = false; |
| 366 total_bytes_ = 0; | 367 total_bytes_ = 0; |
| 367 video_width_ = 0; | 368 video_width_ = 0; |
| 368 video_height_ = 0; | 369 video_height_ = 0; |
| 369 volume_ = 1.0f; | 370 volume_ = 1.0f; |
| 370 preload_ = AUTO; | 371 preload_ = AUTO; |
| 371 playback_rate_ = 0.0f; | 372 playback_rate_ = 0.0f; |
| 373 pending_playback_rate_ = 0.0f; | |
| 372 status_ = PIPELINE_OK; | 374 status_ = PIPELINE_OK; |
| 373 has_audio_ = false; | 375 has_audio_ = false; |
| 374 has_video_ = false; | 376 has_video_ = false; |
| 375 waiting_for_clock_update_ = false; | 377 waiting_for_clock_update_ = false; |
| 376 audio_disabled_ = false; | 378 audio_disabled_ = false; |
| 377 clock_->SetTime(kZero); | 379 clock_->SetTime(kZero); |
| 378 } | 380 } |
| 379 | 381 |
| 380 void PipelineImpl::set_state(State next_state) { | 382 void PipelineImpl::set_state(State next_state) { |
| 381 state_ = next_state; | 383 state_ = next_state; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 // it runs after any pending callbacks that are already queued. | 775 // it runs after any pending callbacks that are already queued. |
| 774 // |tearing_down_| is set early here to make sure that pending callbacks | 776 // |tearing_down_| is set early here to make sure that pending callbacks |
| 775 // don't modify the state before TeadDownPipeline() can run. | 777 // don't modify the state before TeadDownPipeline() can run. |
| 776 tearing_down_ = true; | 778 tearing_down_ = true; |
| 777 message_loop_->PostTask(FROM_HERE, | 779 message_loop_->PostTask(FROM_HERE, |
| 778 NewRunnableMethod(this, &PipelineImpl::TearDownPipeline)); | 780 NewRunnableMethod(this, &PipelineImpl::TearDownPipeline)); |
| 779 } | 781 } |
| 780 | 782 |
| 781 void PipelineImpl::PlaybackRateChangedTask(float playback_rate) { | 783 void PipelineImpl::PlaybackRateChangedTask(float playback_rate) { |
| 782 DCHECK_EQ(MessageLoop::current(), message_loop_); | 784 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 785 | |
| 786 // Suppress rate change until after seeking. | |
| 787 if (IsPipelineSeeking()) { | |
| 788 base::AutoLock auto_lock(lock_); | |
|
scherkus (not reviewing)
2011/04/11 22:32:33
I believe we don't need the lock here since both o
| |
| 789 pending_playback_rate_ = playback_rate; | |
| 790 playback_rate_change_pending_ = true; | |
| 791 return; | |
| 792 } | |
| 793 | |
| 783 { | 794 { |
| 784 base::AutoLock auto_lock(lock_); | 795 base::AutoLock auto_lock(lock_); |
| 785 clock_->SetPlaybackRate(playback_rate); | 796 clock_->SetPlaybackRate(playback_rate); |
| 786 } | 797 } |
| 787 | 798 |
| 788 // Notify |pipeline_filter_| if it has been initialized. If initialization | 799 // Notify |pipeline_filter_| if it has been initialized. If initialization |
| 789 // hasn't completed yet, the playback rate will be set when initialization | 800 // hasn't completed yet, the playback rate will be set when initialization |
| 790 // completes. | 801 // completes. |
| 791 if (pipeline_filter_) { | 802 if (pipeline_filter_) { |
| 792 pipeline_filter_->SetPlaybackRate(playback_rate); | 803 pipeline_filter_->SetPlaybackRate(playback_rate); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 } else { | 963 } else { |
| 953 NOTREACHED() << "Unexpected state: " << state_; | 964 NOTREACHED() << "Unexpected state: " << state_; |
| 954 } | 965 } |
| 955 } else if (state_ == kStarted) { | 966 } else if (state_ == kStarted) { |
| 956 FinishInitialization(); | 967 FinishInitialization(); |
| 957 | 968 |
| 958 // Finally, reset our seeking timestamp back to zero. | 969 // Finally, reset our seeking timestamp back to zero. |
| 959 seek_timestamp_ = base::TimeDelta(); | 970 seek_timestamp_ = base::TimeDelta(); |
| 960 seek_pending_ = false; | 971 seek_pending_ = false; |
| 961 | 972 |
| 973 // If a playback rate change was requested during a seek, do it now that | |
| 974 // the seek has compelted. | |
| 975 if (playback_rate_change_pending_) { | |
| 976 playback_rate_change_pending_ = false; | |
| 977 PlaybackRateChangedTask(pending_playback_rate_); | |
| 978 } | |
| 979 | |
| 962 base::AutoLock auto_lock(lock_); | 980 base::AutoLock auto_lock(lock_); |
| 963 // We use audio stream to update the clock. So if there is such a stream, | 981 // We use audio stream to update the clock. So if there is such a stream, |
| 964 // we pause the clock until we receive a valid timestamp. | 982 // we pause the clock until we receive a valid timestamp. |
| 965 waiting_for_clock_update_ = has_audio_; | 983 waiting_for_clock_update_ = has_audio_; |
| 966 if (!waiting_for_clock_update_) | 984 if (!waiting_for_clock_update_) |
| 967 clock_->Play(); | 985 clock_->Play(); |
| 968 | 986 |
| 969 if (IsPipelineStopPending()) { | 987 if (IsPipelineStopPending()) { |
| 970 // We had a pending stop request need to be honored right now. | 988 // We had a pending stop request need to be honored right now. |
| 971 TearDownPipeline(); | 989 TearDownPipeline(); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1256 case kStopping: | 1274 case kStopping: |
| 1257 case kStopped: | 1275 case kStopped: |
| 1258 NOTREACHED() << "Unexpected state for teardown: " << state_; | 1276 NOTREACHED() << "Unexpected state for teardown: " << state_; |
| 1259 break; | 1277 break; |
| 1260 // default: intentionally left out to force new states to cause compiler | 1278 // default: intentionally left out to force new states to cause compiler |
| 1261 // errors. | 1279 // errors. |
| 1262 }; | 1280 }; |
| 1263 } | 1281 } |
| 1264 | 1282 |
| 1265 } // namespace media | 1283 } // namespace media |
| OLD | NEW |