| Index: media/filters/renderer_impl.cc
|
| diff --git a/media/filters/renderer_impl.cc b/media/filters/renderer_impl.cc
|
| index a2b0d99ec5f003c7fb14a1f3d1dde3acfec17b79..b8005d409d8218f725cced19056b8d8c4b696b04 100644
|
| --- a/media/filters/renderer_impl.cc
|
| +++ b/media/filters/renderer_impl.cc
|
| @@ -50,11 +50,14 @@ RendererImpl::~RendererImpl() {
|
| video_renderer_.reset();
|
| audio_renderer_.reset();
|
|
|
| - FireAllPendingCallbacks();
|
| + if (!init_cb_.is_null())
|
| + base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
|
| + else if (!flush_cb_.is_null())
|
| + base::ResetAndReturn(&flush_cb_).Run();
|
| }
|
|
|
| void RendererImpl::Initialize(DemuxerStreamProvider* demuxer_stream_provider,
|
| - const base::Closure& init_cb,
|
| + const PipelineStatusCB& init_cb,
|
| const StatisticsCB& statistics_cb,
|
| const BufferingStateCB& buffering_state_cb,
|
| const PaintCB& paint_cb,
|
| @@ -262,16 +265,19 @@ void RendererImpl::OnAudioRendererInitializeDone(PipelineStatus status) {
|
| DVLOG(1) << __FUNCTION__ << ": " << status;
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| - if (status != PIPELINE_OK)
|
| - OnError(status);
|
| -
|
| // OnError() may be fired at any time by the renderers, even if they thought
|
| // they initialized successfully (due to delayed output device setup).
|
| if (state_ != STATE_INITIALIZING) {
|
| + DCHECK(init_cb_.is_null());
|
| audio_renderer_.reset();
|
| return;
|
| }
|
|
|
| + if (status != PIPELINE_OK) {
|
| + base::ResetAndReturn(&init_cb_).Run(status);
|
| + return;
|
| + }
|
| +
|
| DCHECK(!init_cb_.is_null());
|
| InitializeVideoRenderer();
|
| }
|
| @@ -308,12 +314,10 @@ void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) {
|
| DVLOG(1) << __FUNCTION__ << ": " << status;
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| - if (status != PIPELINE_OK)
|
| - OnError(status);
|
| -
|
| // OnError() may be fired at any time by the renderers, even if they thought
|
| // they initialized successfully (due to delayed output device setup).
|
| if (state_ != STATE_INITIALIZING) {
|
| + DCHECK(init_cb_.is_null());
|
| audio_renderer_.reset();
|
| video_renderer_.reset();
|
| return;
|
| @@ -321,6 +325,11 @@ void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) {
|
|
|
| DCHECK(!init_cb_.is_null());
|
|
|
| + if (status != PIPELINE_OK) {
|
| + base::ResetAndReturn(&init_cb_).Run(status);
|
| + return;
|
| + }
|
| +
|
| if (audio_renderer_) {
|
| time_source_ = audio_renderer_->GetTimeSource();
|
| } else {
|
| @@ -331,7 +340,7 @@ void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) {
|
| state_ = STATE_PLAYING;
|
| DCHECK(time_source_);
|
| DCHECK(audio_renderer_ || video_renderer_);
|
| - base::ResetAndReturn(&init_cb_).Run();
|
| + base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
|
| }
|
|
|
| void RendererImpl::FlushAudioRenderer() {
|
| @@ -549,19 +558,16 @@ void RendererImpl::OnError(PipelineStatus error) {
|
| if (state_ == STATE_ERROR)
|
| return;
|
|
|
| + const State old_state = state_;
|
| state_ = STATE_ERROR;
|
|
|
| - // Pipeline will destroy |this| as the result of error.
|
| - base::ResetAndReturn(&error_cb_).Run(error);
|
| -
|
| - FireAllPendingCallbacks();
|
| -}
|
| -
|
| -void RendererImpl::FireAllPendingCallbacks() {
|
| - DCHECK(task_runner_->BelongsToCurrentThread());
|
| + if (old_state == STATE_INITIALIZING) {
|
| + base::ResetAndReturn(&init_cb_).Run(error);
|
| + return;
|
| + }
|
|
|
| - if (!init_cb_.is_null())
|
| - base::ResetAndReturn(&init_cb_).Run();
|
| + // After OnError() returns, the pipeline may destroy |this|.
|
| + base::ResetAndReturn(&error_cb_).Run(error);
|
|
|
| if (!flush_cb_.is_null())
|
| base::ResetAndReturn(&flush_cb_).Run();
|
|
|