From 29ae1a90775c019ecba7d7386c28beaa8b521f32 Mon Sep 17 00:00:00 2001 From: Thomas Guilbert Date: Sat, 20 Oct 2018 01:53:38 +0000 Subject: [PATCH] Disable "pause on hide" when flinging videos Currently, we sometimes pause videos when they are hidden, as an optimization. This causes videos flung to cast devices to pause as well, since the pause command sent to the FlingingRenderer is forwarded to the cast device. This CL fixes adds a new flag to track whether or not we are currently flinging a video, and disables ShouldPauseVideoWhenHidden() when we are. Bug: 790766 Change-Id: I7729ab2c8187ffd1c77ebb6c48301165dea1d90f Reviewed-on: https://chromium-review.googlesource.com/c/1292820 Reviewed-by: Dan Sanders Commit-Queue: Thomas Guilbert Cr-Commit-Position: refs/heads/master@{#601386} --- media/blink/webmediaplayer_impl.cc | 8 ++++++-- media/blink/webmediaplayer_impl.h | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index fcc901633f6fb7..c3747a06cbe53d 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc @@ -2262,6 +2262,8 @@ void WebMediaPlayerImpl::FlingingStarted() { DCHECK(!disable_pipeline_auto_suspend_); disable_pipeline_auto_suspend_ = true; + is_flinging_ = true; + // Capabilities reporting should only be performed for local playbacks. video_decode_stats_reporter_.reset(); @@ -2275,6 +2277,8 @@ void WebMediaPlayerImpl::FlingingStopped() { DCHECK(disable_pipeline_auto_suspend_); disable_pipeline_auto_suspend_ = false; + is_flinging_ = false; + CreateVideoDecodeStatsReporter(); ScheduleRestart(); @@ -3071,7 +3075,7 @@ bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { return false; #if defined(OS_ANDROID) - if (IsRemote()) + if (IsRemote() || is_flinging_) return false; #endif @@ -3082,7 +3086,7 @@ bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const { // Otherwise only pause if the optimization is on and it's a video-only // optimization candidate. return IsBackgroundVideoPauseOptimizationEnabled() && !HasAudio() && - IsBackgroundOptimizationCandidate(); + IsBackgroundOptimizationCandidate() && !is_flinging_; } bool WebMediaPlayerImpl::ShouldDisableVideoWhenHidden() const { diff --git a/media/blink/webmediaplayer_impl.h b/media/blink/webmediaplayer_impl.h index d025b8139ad7ab..72a8195e893c6a 100644 --- a/media/blink/webmediaplayer_impl.h +++ b/media/blink/webmediaplayer_impl.h @@ -761,6 +761,12 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl // the pipeline. std::unique_ptr pending_cdm_context_ref_; + // Tracks if we are currently flinging a video (e.g. in a RemotePlayback + // session). Used to prevent videos from being paused when hidden. + // TODO(https://crbug.com/839651): remove or rename this flag, when removing + // IsRemote(). + bool is_flinging_ = false; + #if defined(OS_ANDROID) // WMPI_CAST WebMediaPlayerCast cast_impl_; #endif