Chromium Code Reviews| Index: media/blink/webmediaplayer_impl.cc |
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
| index 4b0474b2c42132467ff4900cec27962d897b0d46..78f37c1ccaa6425b101531460d51ad9f690937a5 100644 |
| --- a/media/blink/webmediaplayer_impl.cc |
| +++ b/media/blink/webmediaplayer_impl.cc |
| @@ -336,6 +336,8 @@ void WebMediaPlayerImpl::DisableOverlay() { |
| if (decoder_requires_restart_for_overlay_) |
| ScheduleRestart(); |
| + else if (!pending_surface_request_cb_.is_null()) |
| + pending_surface_request_cb_.Run(overlay_surface_id_); |
| } |
| void WebMediaPlayerImpl::enteredFullscreen() { |
| @@ -1459,12 +1461,17 @@ void WebMediaPlayerImpl::OnSurfaceCreated(int surface_id) { |
| LOG(ERROR) << "Create surface failed."; |
| overlay_surface_id_ = surface_id; |
| - if (!pending_surface_request_cb_.is_null()) |
| - base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); |
| + if (!pending_surface_request_cb_.is_null()) { |
| + if (decoder_requires_restart_for_overlay_) |
| + base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); |
| + else |
| + pending_surface_request_cb_.Run(surface_id); |
| + } |
| } |
| // TODO(watk): Move this state management out of WMPI. |
| void WebMediaPlayerImpl::OnSurfaceRequested( |
|
watk
2016/11/03 20:26:34
Naming suggestion for when the time comes. This fe
DaleCurtis
2016/11/04 01:07:22
Agreed I don't like the name, but since the mechan
|
| + bool decoder_requires_restart_for_overlay, |
| const SurfaceCreatedCB& surface_created_cb) { |
| DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| DCHECK(surface_manager_); |
| @@ -1472,6 +1479,7 @@ void WebMediaPlayerImpl::OnSurfaceRequested( |
| // A null callback indicates that the decoder is going away. |
| if (surface_created_cb.is_null()) { |
| + DCHECK(!decoder_requires_restart_for_overlay); |
| decoder_requires_restart_for_overlay_ = false; |
| pending_surface_request_cb_.Reset(); |
| return; |
| @@ -1484,7 +1492,9 @@ void WebMediaPlayerImpl::OnSurfaceRequested( |
| // of surface for the fullscreen state. |
| // TODO(watk): Don't require a pipeline restart to switch surfaces for |
| // cases where it isn't necessary. |
| - decoder_requires_restart_for_overlay_ = true; |
| + decoder_requires_restart_for_overlay_ = decoder_requires_restart_for_overlay; |
| + if (!decoder_requires_restart_for_overlay_) |
| + pending_surface_request_cb_ = surface_created_cb; |
| if (overlay_enabled_) { |
| if (overlay_surface_id_ != SurfaceManager::kNoSurfaceID) |
| surface_created_cb.Run(overlay_surface_id_); |