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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 1798213002: Disable "pause-and-buffer" on Android, cancel suspended players. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test bug. Created 4 years, 9 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
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 003d084d7aa973ba04948c9bddf7341192395248..c616635a17f3588e325a8383f6fde474afd779bb 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -537,8 +537,17 @@ void WebMediaPlayerImpl::setBufferingStrategy(
DVLOG(1) << __FUNCTION__;
DCHECK(main_task_runner_->BelongsToCurrentThread());
+#if defined(OS_ANDROID)
+ // We disallow aggressive buffering on Android since it matches the behavior
+ // of the platform media player and may have data usage penalties.
+ // TODO(dalecurtis, hubbe): We should probably stop using "pause-and-buffer"
+ // everywhere. See http://crbug.com/594669 for more details.
+ buffering_strategy_ = BufferedDataSource::BUFFERING_STRATEGY_NORMAL;
+#else
buffering_strategy_ =
static_cast<BufferedDataSource::BufferingStrategy>(buffering_strategy);
+#endif
+
if (data_source_)
data_source_->SetBufferingStrategy(buffering_strategy_);
}
@@ -873,6 +882,13 @@ void WebMediaPlayerImpl::OnPipelineSuspended() {
memory_usage_reporting_timer_.Stop();
ReportMemoryUsage();
+ // If we're not in an aggressive buffering state, tell the data source we have
+ // enough data so that it may release the connection.
+ if (buffering_strategy_ !=
+ BufferedDataSource::BUFFERING_STRATEGY_AGGRESSIVE) {
+ data_source_->OnBufferingHaveEnough(true);
+ }
+
if (pending_suspend_resume_cycle_) {
pending_suspend_resume_cycle_ = false;
pipeline_controller_.Resume();
@@ -972,7 +988,7 @@ void WebMediaPlayerImpl::OnPipelineBufferingStateChanged(
// Let the DataSource know we have enough data. It may use this information to
// release unused network connections.
if (data_source_)
- data_source_->OnBufferingHaveEnough();
+ data_source_->OnBufferingHaveEnough(false);
// Blink expects a timeChanged() in response to a seek().
if (should_notify_time_changed_)
@@ -1030,6 +1046,9 @@ void WebMediaPlayerImpl::OnHidden() {
if (!hasVideo() && !paused_ && !ended_)
return;
+ // Always reset the buffering strategy to normal when suspending for hidden to
+ // prevent an idle network connection from lingering.
+ setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal);
pipeline_controller_.Suspend();
if (delegate_)
delegate_->PlayerGone(delegate_id_);
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698