Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: media/base/pipeline_impl.cc

Issue 160298: Pipeline will execute a callback whenever an run-time error has happened. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline_impl.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 bool PipelineImpl::IsStreaming() const { 240 bool PipelineImpl::IsStreaming() const {
241 AutoLock auto_lock(lock_); 241 AutoLock auto_lock(lock_);
242 return streaming_; 242 return streaming_;
243 } 243 }
244 244
245 PipelineError PipelineImpl::GetError() const { 245 PipelineError PipelineImpl::GetError() const {
246 AutoLock auto_lock(lock_); 246 AutoLock auto_lock(lock_);
247 return error_; 247 return error_;
248 } 248 }
249 249
250 void PipelineImpl::SetPipelineErrorCallback(PipelineCallback* error_callback) {
251 error_callback_.reset(error_callback);
252 }
253
250 void PipelineImpl::ResetState() { 254 void PipelineImpl::ResetState() {
251 AutoLock auto_lock(lock_); 255 AutoLock auto_lock(lock_);
252 const base::TimeDelta kZero; 256 const base::TimeDelta kZero;
253 running_ = false; 257 running_ = false;
254 duration_ = kZero; 258 duration_ = kZero;
255 buffered_time_ = kZero; 259 buffered_time_ = kZero;
256 buffered_bytes_ = 0; 260 buffered_bytes_ = 0;
257 streaming_ = false; 261 streaming_ = false;
258 total_bytes_ = 0; 262 total_bytes_ = 0;
259 video_width_ = 0; 263 video_width_ = 0;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 seek_callback_->Run(); 548 seek_callback_->Run();
545 } 549 }
546 seek_callback_.reset(); 550 seek_callback_.reset();
547 filter_factory_ = NULL; 551 filter_factory_ = NULL;
548 552
549 // We no longer need to examine our previous state, set it to stopped. 553 // We no longer need to examine our previous state, set it to stopped.
550 state_ = kError; 554 state_ = kError;
551 555
552 // Destroy every filter and reset the pipeline as well. 556 // Destroy every filter and reset the pipeline as well.
553 DestroyFilters(); 557 DestroyFilters();
558
559 // If our owner has requested to be notified of an error, execute
560 // |error_callback_| unless we have a "good" error.
561 if (error_callback_.get() && error != PIPELINE_STOPPING) {
562 error_callback_->Run();
563 }
554 } 564 }
555 565
556 void PipelineImpl::PlaybackRateChangedTask(float playback_rate) { 566 void PipelineImpl::PlaybackRateChangedTask(float playback_rate) {
557 DCHECK_EQ(MessageLoop::current(), message_loop_); 567 DCHECK_EQ(MessageLoop::current(), message_loop_);
558 clock_.SetPlaybackRate(playback_rate); 568 clock_.SetPlaybackRate(playback_rate);
559 for (FilterVector::iterator iter = filters_.begin(); 569 for (FilterVector::iterator iter = filters_.begin();
560 iter != filters_.end(); 570 iter != filters_.end();
561 ++iter) { 571 ++iter) {
562 (*iter)->SetPlaybackRate(playback_rate); 572 (*iter)->SetPlaybackRate(playback_rate);
563 } 573 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 830
821 // Reset the pipeline, which will decrement a reference to this object. 831 // Reset the pipeline, which will decrement a reference to this object.
822 // We will get destroyed as soon as the remaining tasks finish executing. 832 // We will get destroyed as soon as the remaining tasks finish executing.
823 // To be safe, we'll set our pipeline reference to NULL. 833 // To be safe, we'll set our pipeline reference to NULL.
824 filters_.clear(); 834 filters_.clear();
825 filter_types_.clear(); 835 filter_types_.clear();
826 STLDeleteElements(&filter_threads_); 836 STLDeleteElements(&filter_threads_);
827 } 837 }
828 838
829 } // namespace media 839 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_impl.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698