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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java

Issue 2111163002: Fixing MediaSessionDelegateAndroid referencing destroyed MediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java b/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
index 06fa64520e3460cc1498292325f5b4787dda8d01..af648e329564d70b178e2787597b851748272875 100644
--- a/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
+++ b/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
@@ -34,8 +34,9 @@ public class MediaSessionDelegate implements AudioManager.OnAudioFocusChangeList
private int mFocusType;
private boolean mIsDucking = false;
- // Native pointer to C++ content::MediaSessionAndroid.
- private final long mNativeMediaSessionDelegateAndroid;
+ // Native pointer to C++ content::MediaSessionDelegateAndroid.
+ // It will be set to 0 when the native MediaSessionDelegateAndroid object is destroyed.
+ private long mNativeMediaSessionDelegateAndroid;
private MediaSessionDelegate(final Context context, long nativeMediaSessionDelegateAndroid) {
mContext = context;
@@ -51,6 +52,7 @@ public class MediaSessionDelegate implements AudioManager.OnAudioFocusChangeList
@CalledByNative
private void tearDown() {
abandonAudioFocus();
+ mNativeMediaSessionDelegateAndroid = 0;
}
@CalledByNative
@@ -75,6 +77,8 @@ public class MediaSessionDelegate implements AudioManager.OnAudioFocusChangeList
@Override
public void onAudioFocusChange(int focusChange) {
+ if (mNativeMediaSessionDelegateAndroid == 0) return;
+
switch (focusChange) {
case AudioManager.AUDIOFOCUS_GAIN:
if (mIsDucking) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698