Chromium Code Reviews| Index: media/filters/renderer_impl.cc |
| diff --git a/media/filters/renderer_impl.cc b/media/filters/renderer_impl.cc |
| index a2b0d99ec5f003c7fb14a1f3d1dde3acfec17b79..3f3a98fa890752a2ee4bb94a3a04cd9e3d6af320 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(); |
| + if (!init_cb_.is_null()) |
| + base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); |
|
xhwang
2015/01/23 21:03:07
I don't think we could have |flush_cb| during init
DaleCurtis
2015/01/23 21:19:42
Changed to else.
|
| + |
| FireAllPendingCallbacks(); |
| } |
| 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,20 +558,21 @@ void RendererImpl::OnError(PipelineStatus error) { |
| if (state_ == STATE_ERROR) |
| return; |
| + const State old_state = state_; |
| state_ = STATE_ERROR; |
| + if (old_state == STATE_INITIALIZING) { |
| + base::ResetAndReturn(&init_cb_).Run(error); |
| + return; |
| + } |
| + |
| // Pipeline will destroy |this| as the result of error. |
| base::ResetAndReturn(&error_cb_).Run(error); |
| - |
| FireAllPendingCallbacks(); |
| } |
| void RendererImpl::FireAllPendingCallbacks() { |
|
xhwang
2015/01/23 21:03:07
Now this function only fires |flush_cb_|, maybe we
DaleCurtis
2015/01/23 21:19:42
Agreed.
|
| DCHECK(task_runner_->BelongsToCurrentThread()); |
| - |
| - if (!init_cb_.is_null()) |
| - base::ResetAndReturn(&init_cb_).Run(); |
| - |
| if (!flush_cb_.is_null()) |
| base::ResetAndReturn(&flush_cb_).Run(); |
| } |