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

Unified Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1766783003: Expand suspension of idle media players to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notify_pause
Patch Set: Cleanup. Created 4 years, 10 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: content/renderer/media/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 32c68c82993569c0efb0a819aa4654c409fe9da8..91d163af348ca11b160e937810ad831143a2d609 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -144,6 +144,11 @@ bool AllocateSkBitmapTexture(GrContext* gr,
return true;
}
+bool IsSuspendResumeEnabled() {
+ return !base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableMediaSuspend);
+}
+
class SyncTokenClientImpl : public media::VideoFrame::SyncTokenClient {
public:
explicit SyncTokenClientImpl(
@@ -1513,21 +1518,24 @@ void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() {
encrypted_client_->didResumePlaybackBlockedForKey();
}
-void WebMediaPlayerAndroid::OnHidden(bool must_suspend) {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableMediaSuspend)) {
+void WebMediaPlayerAndroid::OnHidden() {
+ if (!IsSuspendResumeEnabled())
return;
- }
// If we're idle or playing video, pause and release resources; audio only
// players are allowed to continue playing in the background unless indicated
// otherwise by the call.
- if (must_suspend || (paused() && playback_completed_) || hasVideo())
+ if ((paused() && playback_completed_) || hasVideo())
SuspendAndReleaseResources();
}
void WebMediaPlayerAndroid::OnShown() {}
+void WebMediaPlayerAndroid::OnSuspend(bool must_suspend) {
+ if (must_suspend)
+ SuspendAndReleaseResources();
+}
+
void WebMediaPlayerAndroid::OnPlay() {
play();
client_->playbackStateChanged();

Powered by Google App Engine
This is Rietveld 408576698