| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 media::PipelineStatus PipelineStatusNotification::status() { | 58 media::PipelineStatus PipelineStatusNotification::status() { |
| 59 base::AutoLock auto_lock(lock_); | 59 base::AutoLock auto_lock(lock_); |
| 60 DCHECK(notified_); | 60 DCHECK(notified_); |
| 61 return status_; | 61 return status_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 struct Pipeline::PipelineInitState { | 64 struct Pipeline::PipelineInitState { |
| 65 scoped_refptr<AudioDecoder> audio_decoder; | 65 scoped_refptr<AudioDecoder> audio_decoder; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 Pipeline::Pipeline(MessageLoop* message_loop, MediaLog* media_log) | 68 Pipeline::Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 69 : message_loop_(message_loop->message_loop_proxy()), | 69 MediaLog* media_log) |
| 70 : message_loop_(message_loop), |
| 70 media_log_(media_log), | 71 media_log_(media_log), |
| 71 running_(false), | 72 running_(false), |
| 72 seek_pending_(false), | 73 seek_pending_(false), |
| 73 tearing_down_(false), | 74 tearing_down_(false), |
| 74 playback_rate_change_pending_(false), | 75 playback_rate_change_pending_(false), |
| 75 did_loading_progress_(false), | 76 did_loading_progress_(false), |
| 76 total_bytes_(0), | 77 total_bytes_(0), |
| 77 natural_size_(0, 0), | 78 natural_size_(0, 0), |
| 78 volume_(1.0f), | 79 volume_(1.0f), |
| 79 playback_rate_(0.0f), | 80 playback_rate_(0.0f), |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // Continue the initialize task by proceeding to the next stage. | 514 // Continue the initialize task by proceeding to the next stage. |
| 514 message_loop_->PostTask(FROM_HERE, base::Bind( | 515 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 515 &Pipeline::InitializeTask, this, status)); | 516 &Pipeline::InitializeTask, this, status)); |
| 516 } | 517 } |
| 517 | 518 |
| 518 // Called from any thread. | 519 // Called from any thread. |
| 519 // This method makes the PipelineStatusCB behave like a Closure. It | 520 // This method makes the PipelineStatusCB behave like a Closure. It |
| 520 // makes it look like a host()->SetError() call followed by a call to | 521 // makes it look like a host()->SetError() call followed by a call to |
| 521 // OnFilterStateTransition() when errors occur. | 522 // OnFilterStateTransition() when errors occur. |
| 522 // | 523 // |
| 523 // TODO: Revisit this code when SetError() is removed from FilterHost and | 524 // TODO(scherkus): Revisit this code when SetError() is removed from FilterHost |
| 524 // all the Closures are converted to PipelineStatusCB. | 525 // and all the Closures are converted to PipelineStatusCB. |
| 525 void Pipeline::OnFilterStateTransition(PipelineStatus status) { | 526 void Pipeline::OnFilterStateTransition(PipelineStatus status) { |
| 526 if (status != PIPELINE_OK) | 527 if (status != PIPELINE_OK) |
| 527 SetError(status); | 528 SetError(status); |
| 528 message_loop_->PostTask(FROM_HERE, base::Bind( | 529 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 529 &Pipeline::FilterStateTransitionTask, this)); | 530 &Pipeline::FilterStateTransitionTask, this)); |
| 530 } | 531 } |
| 531 | 532 |
| 532 void Pipeline::OnTeardownStateTransition(PipelineStatus status) { | 533 void Pipeline::OnTeardownStateTransition(PipelineStatus status) { |
| 533 // Ignore any errors during teardown. | 534 // Ignore any errors during teardown. |
| 534 message_loop_->PostTask(FROM_HERE, base::Bind( | 535 message_loop_->PostTask(FROM_HERE, base::Bind( |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1211 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
| 1211 lock_.AssertAcquired(); | 1212 lock_.AssertAcquired(); |
| 1212 if (!waiting_for_clock_update_) | 1213 if (!waiting_for_clock_update_) |
| 1213 return; | 1214 return; |
| 1214 | 1215 |
| 1215 waiting_for_clock_update_ = false; | 1216 waiting_for_clock_update_ = false; |
| 1216 clock_->Play(); | 1217 clock_->Play(); |
| 1217 } | 1218 } |
| 1218 | 1219 |
| 1219 } // namespace media | 1220 } // namespace media |
| OLD | NEW |