Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2445533002: Don't suspend the pipeline before HaveFutureData while decoding progressing (Closed)
Patch Set: Use loading progress instead of decoding progress Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 6bdb267db295750a9d56df5ee433ed1e6254d9a7..37306d7b322d5e686f8fd5b51e0237739654e343 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -236,6 +236,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
DCHECK(renderer_factory_);
DCHECK(client_);
+ tick_clock_ = &default_tick_clock_;
+
force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForceVideoOverlays);
@@ -782,6 +784,9 @@ bool WebMediaPlayerImpl::didLoadingProgress() {
UpdatePlayState();
}
+ if (did_loading_progress)
+ last_time_loading_progressed_ = tick_clock_->NowTicks();
+
return did_loading_progress;
}
@@ -1311,12 +1316,31 @@ void WebMediaPlayerImpl::OnShown() {
void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
- if (must_suspend)
+ if (must_suspend) {
must_suspend_ = true;
- else
+ UpdatePlayState();
+ return;
+ }
+
+ // If we're beyond HaveFutureData, we can safely suspend at any time.
+ if (highest_ready_state_ >= WebMediaPlayer::ReadyStateHaveFutureData) {
is_idle_ = true;
+ UpdatePlayState();
+ return;
+ }
- UpdatePlayState();
+ // Before HaveFutureData blink will not call play(), so we must be careful to
DaleCurtis 2016/10/28 19:11:42 This will never be called again. So even after 3 s
watk 2016/10/28 20:03:22 What about calling delegate_->DidPause()? Then the
+ // only suspend if we'll eventually receive an event that will trigger a
+ // resume. If the last time loading progressed was longer than 3 seconds ago,
+ // and we still haven't reached HaveFutureData, assume that we're waiting on
+ // more data to proceed. When that data is loaded the pipeline will be resumed
+ // by didLoadingProgress().
+ if (last_time_loading_progressed_.is_null() ||
+ (tick_clock_->NowTicks() - last_time_loading_progressed_) >
+ base::TimeDelta::FromSeconds(3)) {
+ is_idle_ = true;
+ UpdatePlayState();
+ }
}
void WebMediaPlayerImpl::OnPlay() {

Powered by Google App Engine
This is Rietveld 408576698