[Android] Fix potential crash on AudioFocus loss

Jean-Baptiste Kempf git at videolan.org
Sat Aug 2 21:11:18 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Aug  2 21:10:39 2014 +0200| [49174a6f3a32debc164a9294a2a2bbf4c8bc0f88] | committer: Jean-Baptiste Kempf

Fix potential crash on AudioFocus loss

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=49174a6f3a32debc164a9294a2a2bbf4c8bc0f88
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 86cf5de..e83f5dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -810,8 +810,12 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             mAudioManager.setParameters("bgm_state=true");
         }
         else {
-            result = mAudioManager.abandonAudioFocus(mAudioFocusListener);
-            mAudioManager.setParameters("bgm_state=false");
+            if (mAudioManager != null) {
+                result = mAudioManager.abandonAudioFocus(mAudioFocusListener);
+                mAudioManager.setParameters("bgm_state=false");
+            }
+            else
+                result = AudioManager.AUDIOFOCUS_REQUEST_FAILED;
         }
 
         return result;



More information about the Android mailing list