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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 1815893002: Merge M50: "Disable "pause-and-buffer" on Android, cancel suspended players." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: 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 c48e4bd9ddb092e00eff75e01a4f459cad89fcf0..1f8b3405a578c8228aa126b685effbc4492bcc89 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -560,8 +560,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_);
}
@@ -960,6 +969,14 @@ void WebMediaPlayerImpl::OnPipelineSuspended(PipelineStatus status) {
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) {
+ if (data_source_)
+ data_source_->OnBufferingHaveEnough(true);
+ }
+
if (pending_resume_ || pending_suspend_resume_cycle_) {
pending_resume_ = false;
pending_suspend_resume_cycle_ = false;
@@ -1050,7 +1067,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_)
@@ -1120,6 +1137,9 @@ void WebMediaPlayerImpl::ScheduleSuspend() {
if (!pipeline_.IsRunning())
return;
+ // Always reset the buffering strategy to normal when suspending for hidden to
+ // prevent an idle network connection from lingering.
+ setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal);
if (resuming_ || seeking_) {
pending_suspend_ = true;
return;
« 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