| OLD | NEW |
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/condition_variable.h" | 9 #include "base/condition_variable.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 | 165 |
| 166 AutoLock auto_lock(lock_); | 166 AutoLock auto_lock(lock_); |
| 167 volume_ = volume; | 167 volume_ = volume; |
| 168 if (pipeline_internal_) { | 168 if (pipeline_internal_) { |
| 169 pipeline_internal_->VolumeChanged(volume); | 169 pipeline_internal_->VolumeChanged(volume); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 base::TimeDelta PipelineImpl::GetTime() const { | 173 base::TimeDelta PipelineImpl::GetCurrentTime() const { |
| 174 AutoLock auto_lock(lock_); | 174 AutoLock auto_lock(lock_); |
| 175 return time_; | 175 return time_; |
| 176 } | 176 } |
| 177 | 177 |
| 178 base::TimeDelta PipelineImpl::GetBufferedTime() const { | 178 base::TimeDelta PipelineImpl::GetBufferedTime() const { |
| 179 AutoLock auto_lock(lock_); | 179 AutoLock auto_lock(lock_); |
| 180 return buffered_time_; | 180 return buffered_time_; |
| 181 } | 181 } |
| 182 | 182 |
| 183 base::TimeDelta PipelineImpl::GetDuration() const { | 183 base::TimeDelta PipelineImpl::GetDuration() const { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 // Called from any thread. Updates the pipeline time. | 331 // Called from any thread. Updates the pipeline time. |
| 332 void PipelineInternal::SetTime(base::TimeDelta time) { | 332 void PipelineInternal::SetTime(base::TimeDelta time) { |
| 333 // TODO(scherkus): why not post a task? | 333 // TODO(scherkus): why not post a task? |
| 334 pipeline_->SetTime(time); | 334 pipeline_->SetTime(time); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Called from any thread. Sets the pipeline |error_| member and destroys all | 337 // Called from any thread. Sets the pipeline |error_| member and destroys all |
| 338 // filters. | 338 // filters. |
| 339 void PipelineInternal::Error(PipelineError error) { | 339 void PipelineInternal::SetError(PipelineError error) { |
| 340 message_loop_->PostTask(FROM_HERE, | 340 message_loop_->PostTask(FROM_HERE, |
| 341 NewRunnableMethod(this, &PipelineInternal::ErrorTask, error)); | 341 NewRunnableMethod(this, &PipelineInternal::ErrorTask, error)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Called from any thread. | 344 // Called from any thread. |
| 345 void PipelineInternal::OnFilterInitialize() { | 345 void PipelineInternal::OnFilterInitialize() { |
| 346 // Continue the initialize task by proceeding to the next stage. | 346 // Continue the initialize task by proceeding to the next stage. |
| 347 message_loop_->PostTask(FROM_HERE, | 347 message_loop_->PostTask(FROM_HERE, |
| 348 NewRunnableMethod(this, &PipelineInternal::InitializeTask)); | 348 NewRunnableMethod(this, &PipelineInternal::InitializeTask)); |
| 349 } | 349 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 if (state_ == kInitVideoDecoder) { | 437 if (state_ == kInitVideoDecoder) { |
| 438 state_ = kInitVideoRenderer; | 438 state_ = kInitVideoRenderer; |
| 439 if (CreateRenderer<VideoDecoder, VideoRenderer>()) { | 439 if (CreateRenderer<VideoDecoder, VideoRenderer>()) { |
| 440 pipeline_->InsertRenderedMimeType(VideoDecoder::major_mime_type()); | 440 pipeline_->InsertRenderedMimeType(VideoDecoder::major_mime_type()); |
| 441 return; | 441 return; |
| 442 } | 442 } |
| 443 } | 443 } |
| 444 | 444 |
| 445 if (state_ == kInitVideoRenderer) { | 445 if (state_ == kInitVideoRenderer) { |
| 446 if (!IsPipelineOk() || pipeline_->rendered_mime_types_.empty()) { | 446 if (!IsPipelineOk() || pipeline_->rendered_mime_types_.empty()) { |
| 447 Error(PIPELINE_ERROR_COULD_NOT_RENDER); | 447 SetError(PIPELINE_ERROR_COULD_NOT_RENDER); |
| 448 return; | 448 return; |
| 449 } | 449 } |
| 450 | 450 |
| 451 // Initialization was successful, set the volume and playback rate. | 451 // Initialization was successful, set the volume and playback rate. |
| 452 PlaybackRateChangedTask(pipeline_->GetPlaybackRate()); | 452 PlaybackRateChangedTask(pipeline_->GetPlaybackRate()); |
| 453 VolumeChangedTask(pipeline_->GetVolume()); | 453 VolumeChangedTask(pipeline_->GetVolume()); |
| 454 | 454 |
| 455 state_ = kStarted; | 455 state_ = kStarted; |
| 456 filter_factory_ = NULL; | 456 filter_factory_ = NULL; |
| 457 if (start_callback_.get()) { | 457 if (start_callback_.get()) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 template <class Filter, class Source> | 576 template <class Filter, class Source> |
| 577 void PipelineInternal::CreateFilter(FilterFactory* filter_factory, | 577 void PipelineInternal::CreateFilter(FilterFactory* filter_factory, |
| 578 Source source, | 578 Source source, |
| 579 const MediaFormat& media_format) { | 579 const MediaFormat& media_format) { |
| 580 DCHECK_EQ(MessageLoop::current(), message_loop_); | 580 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 581 DCHECK(IsPipelineOk()); | 581 DCHECK(IsPipelineOk()); |
| 582 | 582 |
| 583 // Create the filter. | 583 // Create the filter. |
| 584 scoped_refptr<Filter> filter = filter_factory->Create<Filter>(media_format); | 584 scoped_refptr<Filter> filter = filter_factory->Create<Filter>(media_format); |
| 585 if (!filter) { | 585 if (!filter) { |
| 586 Error(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 586 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
| 587 return; | 587 return; |
| 588 } | 588 } |
| 589 | 589 |
| 590 // Create a dedicated thread for this filter if applicable. | 590 // Create a dedicated thread for this filter if applicable. |
| 591 if (SupportsSetMessageLoop<Filter>()) { | 591 if (SupportsSetMessageLoop<Filter>()) { |
| 592 scoped_ptr<base::Thread> thread(new base::Thread(GetThreadName<Filter>())); | 592 scoped_ptr<base::Thread> thread(new base::Thread(GetThreadName<Filter>())); |
| 593 if (!thread.get() || !thread->Start()) { | 593 if (!thread.get() || !thread->Start()) { |
| 594 NOTREACHED() << "Could not start filter thread"; | 594 NOTREACHED() << "Could not start filter thread"; |
| 595 Error(PIPELINE_ERROR_INITIALIZATION_FAILED); | 595 SetError(PIPELINE_ERROR_INITIALIZATION_FAILED); |
| 596 return; | 596 return; |
| 597 } | 597 } |
| 598 | 598 |
| 599 filter->set_message_loop(thread->message_loop()); | 599 filter->set_message_loop(thread->message_loop()); |
| 600 filter_threads_.push_back(thread.release()); | 600 filter_threads_.push_back(thread.release()); |
| 601 } | 601 } |
| 602 | 602 |
| 603 // Create the filter's host. | 603 // Create the filter's host. |
| 604 DCHECK(IsPipelineOk()); | 604 DCHECK(IsPipelineOk()); |
| 605 scoped_ptr<FilterHostImpl> host(new FilterHostImpl(this, filter.get())); | 605 scoped_ptr<FilterHostImpl> host(new FilterHostImpl(this, filter.get())); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 726 } |
| 727 | 727 |
| 728 // Reset the pipeline, which will decrement a reference to this object. | 728 // Reset the pipeline, which will decrement a reference to this object. |
| 729 // We will get destroyed as soon as the remaining tasks finish executing. | 729 // We will get destroyed as soon as the remaining tasks finish executing. |
| 730 // To be safe, we'll set our pipeline reference to NULL. | 730 // To be safe, we'll set our pipeline reference to NULL. |
| 731 STLDeleteElements(&filter_hosts_); | 731 STLDeleteElements(&filter_hosts_); |
| 732 STLDeleteElements(&filter_threads_); | 732 STLDeleteElements(&filter_threads_); |
| 733 } | 733 } |
| 734 | 734 |
| 735 } // namespace media | 735 } // namespace media |
| OLD | NEW |