[Android] LibVLC: remove onHardwareAccelerationError event

Thomas Guillem git at videolan.org
Thu Jul 28 15:08:26 CEST 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jul 28 15:02:35 2016 +0200| [632cb95e3737cc5974dd6fae393091d0998c7032] | committer: Thomas Guillem

LibVLC: remove onHardwareAccelerationError event

The VLC core is now capable of handling this error.

> https://code.videolan.org/videolan/vlc-android/commit/632cb95e3737cc5974dd6fae393091d0998c7032
---

 libvlc/src/org/videolan/libvlc/AWindow.java        | 11 ------
 .../org/videolan/libvlc/AWindowNativeHandler.java  |  8 -----
 libvlc/src/org/videolan/libvlc/IVLCVout.java       |  6 ----
 vlc-android/res/values/strings.xml                 |  1 -
 .../src/org/videolan/vlc/PlaybackService.java      |  4 ---
 .../org/videolan/vlc/gui/video/PopupManager.java   |  2 --
 .../vlc/gui/video/VideoPlayerActivity.java         | 39 ++--------------------
 7 files changed, 3 insertions(+), 68 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index 1750b73..9d1b263 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -539,16 +539,5 @@ public class AWindow implements IVLCVout {
                 }
             });
         }
-
-        @Override
-        public void sendHardwareAccelerationError() {
-            mHandler.post(new Runnable() {
-                @Override
-                public void run() {
-                    for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
-                        cb.onHardwareAccelerationError(AWindow.this);
-                }
-            });
-        }
     };
 }
\ No newline at end of file
diff --git a/libvlc/src/org/videolan/libvlc/AWindowNativeHandler.java b/libvlc/src/org/videolan/libvlc/AWindowNativeHandler.java
index 4598f58..6d2bd4e 100644
--- a/libvlc/src/org/videolan/libvlc/AWindowNativeHandler.java
+++ b/libvlc/src/org/videolan/libvlc/AWindowNativeHandler.java
@@ -94,12 +94,4 @@ public abstract class AWindowNativeHandler {
      */
     @SuppressWarnings("unused") /* Used by JNI */
     protected abstract void setWindowLayout(int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen);
-
-    /**
-     * TODO: temporary method, will be removed when VLC can handle decoder fallback
-     * This call will result of {@link IVLCVout.Callback#onHardwareAccelerationError} being called from the main thread.
-     *
-     */
-    @SuppressWarnings("unused") /* Used by JNI */
-    protected abstract void sendHardwareAccelerationError();
 }
\ No newline at end of file
diff --git a/libvlc/src/org/videolan/libvlc/IVLCVout.java b/libvlc/src/org/videolan/libvlc/IVLCVout.java
index 504d8c6..f21b2bc 100644
--- a/libvlc/src/org/videolan/libvlc/IVLCVout.java
+++ b/libvlc/src/org/videolan/libvlc/IVLCVout.java
@@ -57,12 +57,6 @@ public interface IVLCVout {
          */
         @MainThread
         void onSurfacesDestroyed(IVLCVout vlcVout);
-
-        /**
-         * TODO: temporary method, will be removed when VLC can handle decoder fallback
-         */
-        @MainThread
-        void onHardwareAccelerationError(IVLCVout vlcVout);
     }
 
     /**
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index bd16c05..c215cd7 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -432,7 +432,6 @@
     <string name="allow_sdraw_overlays_description">VLC needs you to grant this permission display your video in a popup over other applications.</string>
     <string name="permission_ask_again">Grant permission</string>
     <string name="exit_app">Close VLC</string>
-    <string name="hardware_acceleration_error">hardware acceleration error, switching to software decoding</string>
 
     <!-- PLugins -->
     <string name="plugins">Plugins</string>
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 4dff6eb..6f9c449 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -533,10 +533,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         mSwitchingToVideo = false;
     }
 
-    @Override
-    public void onHardwareAccelerationError(IVLCVout vlcVout) {
-    }
-
     private final Media.EventListener mMediaListener = new Media.EventListener() {
         @Override
         public void onEvent(Media.Event event) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index b98a1ca..ad8db95 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -207,8 +207,6 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
 
     @Override public void onSurfacesDestroyed(IVLCVout vlcVout) {}
 
-    @Override public void onHardwareAccelerationError(IVLCVout vlcVout) {}
-
     @Override
     public void update() {}
 
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 8b17d49..8f931aa 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -213,7 +213,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     private static final int RESET_BACK_LOCK = 6;
     private static final int CHECK_VIDEO_TRACKS = 7;
     private static final int LOADING_ANIMATION = 8;
-    private static final int HW_ERROR = 1000; // TODO REMOVE
 
     private static final int LOADING_ANIMATION_DELAY = 1000;
 
@@ -270,7 +269,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
      */
     private boolean mSwitchingView;
     private boolean mSwitchToPopup;
-    private boolean mHardwareAccelerationError;
     private boolean mHasSubItems = false;
 
     // size of the video
@@ -466,7 +464,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
 
         mSwitchingView = false;
-        mHardwareAccelerationError = false;
 
         mAskResume = mSettings.getBoolean("dialog_confirm_resume", false);
         mDisplayRemainingTime = mSettings.getBoolean(KEY_REMAINING_TIME_DISPLAY, false);
@@ -1653,9 +1650,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 case LOADING_ANIMATION:
                     startLoading();
                     break;
-                case HW_ERROR:
-                    handleHardwareAccelerationError();
-                    break;
             }
             return true;
         }
@@ -1725,28 +1719,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mAlertDialog.show();
     }
 
-    private void handleHardwareAccelerationError() {
-        mHardwareAccelerationError = true;
-        if (mSwitchingView)
-            return;
-        Toast.makeText(VLCApplication.getAppContext(), R.string.hardware_acceleration_error, Toast.LENGTH_LONG).show();
-        final boolean wasPaused = !mService.isPlaying();
-        final long oldTime = mService.getTime();
-        int position = mService.getCurrentMediaPosition();
-        List<MediaWrapper> list = new ArrayList<>(mService.getMedias());
-        final MediaWrapper mw = list.get(position);
-        mService.stop();
-        if(!isFinishing()) {
-            if (wasPaused)
-                mw.addFlags(MediaWrapper.MEDIA_PAUSED);
-            mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
-            mw.addFlags(MediaWrapper.MEDIA_VIDEO);
-            mService.load(list, position);
-            if (oldTime > 0)
-                seek(oldTime);
-        }
-    }
-
     private void handleVout(int voutCount) {
         final IVLCVout vlcVout = mService.getVLCVout();
         if (vlcVout.areViewsAttached() && voutCount == 0) {
@@ -1758,7 +1730,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     public void switchToPopupMode() {
-        if (mHardwareAccelerationError || mService == null)
+        if (mService == null)
             return;
         mSwitchingView = true;
         mSwitchToPopup = true;
@@ -1766,7 +1738,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     public void switchToAudioMode(boolean showUI) {
-        if (mHardwareAccelerationError || mService == null)
+        if (mService == null)
             return;
         mSwitchingView = true;
         // Show the MainActivity if it is not in background.
@@ -2971,7 +2943,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 media = new MediaWrapper(mUri);
             if (mWasPaused)
                 media.addFlags(MediaWrapper.MEDIA_PAUSED);
-            if (mHardwareAccelerationError || intent.hasExtra(PLAY_DISABLE_HARDWARE))
+            if (intent.hasExtra(PLAY_DISABLE_HARDWARE))
                 media.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
             media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
             media.addFlags(MediaWrapper.MEDIA_VIDEO);
@@ -3445,11 +3417,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     public void onSurfacesDestroyed(IVLCVout vlcVout) {
     }
 
-    @Override
-    public void onHardwareAccelerationError(IVLCVout vlcVout) {
-        mHandler.sendEmptyMessage(HW_ERROR);
-    }
-
     private BroadcastReceiver mServiceReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {



More information about the Android mailing list