[Android] [PATCH 3/3] Don't switch to audioMode in case of HardwareAccelerationError

Thomas Guillem tom at gllm.fr
Tue Oct 21 17:11:19 CEST 2014


If a hardware decoder crashed at the very beginning, a HardwareAccelerationError
dialog was shown while activity switched to audioMode and leaded to a crash.
---
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java        | 7 +++++++
 1 file changed, 7 insertions(+)

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 b6eff14..49f21b2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -194,6 +194,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
      * For uninterrupted switching between audio and video mode
      */
     private boolean mSwitchingView;
+    private boolean mHardwareAccelerationError;
     private boolean mEndReached;
     private boolean mCanSeek;
 
@@ -405,6 +406,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         startLoadingAnimation();
 
         mSwitchingView = false;
+        mHardwareAccelerationError = false;
         mEndReached = false;
 
         // Clear the resume time, since it is only used for resumes in external
@@ -1104,6 +1106,9 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
     }
 
     private void handleHardwareAccelerationError() {
+        mHardwareAccelerationError = true;
+        if (mSwitchingView)
+            return;
         mLibVLC.stop();
         AlertDialog dialog = new AlertDialog.Builder(VideoPlayerActivity.this)
         .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@@ -1145,6 +1150,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
     }
 
     private void switchToAudioMode() {
+        if (mHardwareAccelerationError)
+            return;
         mSwitchingView = true;
         // Show the MainActivity if it is not in background.
         if (getIntent().getAction() != null
-- 
2.1.0



More information about the Android mailing list