Skip to content

Commit

Permalink
Disable "pause on hide" when flinging videos
Browse files Browse the repository at this point in the history
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 <sandersd@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601386}
  • Loading branch information
tguilbert-google authored and Commit Bot committed Oct 20, 2018
1 parent 9d39d8b commit 29ae1a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions media/blink/webmediaplayer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -2275,6 +2277,8 @@ void WebMediaPlayerImpl::FlingingStopped() {
DCHECK(disable_pipeline_auto_suspend_);
disable_pipeline_auto_suspend_ = false;

is_flinging_ = false;

CreateVideoDecodeStatsReporter();

ScheduleRestart();
Expand Down Expand Up @@ -3071,7 +3075,7 @@ bool WebMediaPlayerImpl::ShouldPauseVideoWhenHidden() const {
return false;

#if defined(OS_ANDROID)
if (IsRemote())
if (IsRemote() || is_flinging_)
return false;
#endif

Expand All @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions media/blink/webmediaplayer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl
// the pipeline.
std::unique_ptr<CdmContextRef> 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
Expand Down

0 comments on commit 29ae1a9

Please sign in to comment.