[Android] LibVLC: remove eventHardwareAccelerationError

Thomas Guillem git at videolan.org
Mon Feb 22 17:14:47 CET 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb 22 17:00:53 2016 +0100| [bfa9c131c5e5352736e268548850860c897b7e9b] | committer: Thomas Guillem

LibVLC: remove eventHardwareAccelerationError

Replace it with IVLCVout.onHardwareAccelerationError.

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

 libvlc/jni/libvlcjni.c                             | 35 ----------------------
 libvlc/libvlcjni.sym                               |  1 -
 libvlc/src/org/videolan/libvlc/AWindow.java        | 11 +++++++
 .../org/videolan/libvlc/IAWindowNativeHandler.java |  8 +++++
 libvlc/src/org/videolan/libvlc/IVLCVout.java       |  6 ++++
 libvlc/src/org/videolan/libvlc/LibVLC.java         |  9 ------
 .../src/org/videolan/vlc/PlaybackService.java      |  4 +++
 .../vlc/gui/video/VideoPlayerActivity.java         | 16 ++++------
 8 files changed, 35 insertions(+), 55 deletions(-)

diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 9a98fa9..cd326f6 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -479,38 +479,3 @@ int aout_get_native_sample_rate(void)
     int sample_rate = (*p_env)->CallStaticIntMethod (p_env, cls, method, 3); // AudioManager.STREAM_MUSIC
     return sample_rate;
 }
-
-/* TODO REMOVE */
-static jobject error_obj = NULL;
-pthread_mutex_t error_obj_lock;
-
-void Java_org_videolan_libvlc_LibVLC_nativeSetOnHardwareAccelerationError(JNIEnv *env, jobject thiz, jobject error_obj_)
-{
-    pthread_mutex_lock(&error_obj_lock);
-
-    if (error_obj != NULL)
-        (*env)->DeleteGlobalRef(env, error_obj);
-    error_obj = error_obj_ ? (*env)->NewGlobalRef(env, error_obj_) : NULL;
-    pthread_mutex_unlock(&error_obj_lock);
-}
-
-void jni_EventHardwareAccelerationError()
-{
-    JNIEnv *env;
-
-    if (!(env = jni_get_env(THREAD_NAME)))
-        return;
-
-    pthread_mutex_lock(&error_obj_lock);
-    if (error_obj == NULL) {
-        pthread_mutex_unlock(&error_obj_lock);
-        return;
-    }
-
-    jclass cls = (*env)->GetObjectClass(env, error_obj);
-    jmethodID methodId = (*env)->GetMethodID(env, cls, "eventHardwareAccelerationError", "()V");
-    (*env)->CallVoidMethod(env, error_obj, methodId);
-
-    (*env)->DeleteLocalRef(env, cls);
-    pthread_mutex_unlock(&error_obj_lock);
-}
diff --git a/libvlc/libvlcjni.sym b/libvlc/libvlcjni.sym
index 15284a4..e0e32bd 100644
--- a/libvlc/libvlcjni.sym
+++ b/libvlc/libvlcjni.sym
@@ -8,7 +8,6 @@ Java_org_videolan_libvlc_LibVLC_changeset
 Java_org_videolan_libvlc_LibVLC_compiler
 Java_org_videolan_libvlc_LibVLC_nativeNew
 Java_org_videolan_libvlc_LibVLC_nativeRelease
-Java_org_videolan_libvlc_LibVLC_nativeSetOnHardwareAccelerationError
 Java_org_videolan_libvlc_LibVLC_nativeSetUserAgent
 Java_org_videolan_libvlc_LibVLC_version
 Java_org_videolan_libvlc_MediaDiscoverer_nativeList
diff --git a/libvlc/src/org/videolan/libvlc/AWindow.java b/libvlc/src/org/videolan/libvlc/AWindow.java
index eed654e..19251ac 100644
--- a/libvlc/src/org/videolan/libvlc/AWindow.java
+++ b/libvlc/src/org/videolan/libvlc/AWindow.java
@@ -526,6 +526,17 @@ public class AWindow implements IAWindowNativeHandler, IVLCVout {
             }
         });
     }
+
+    @Override
+    public void sendHardwareAccelerationError() {
+        mHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                for (IVLCVout.Callback cb : mIVLCVoutCallbacks)
+                    cb.onHardwareAccelerationError(AWindow.this);
+            }
+        });
+    }
     public native void nativeOnMouseEvent(long nativeHandle, int action, int button, int x, int y);
     public native void nativeOnWindowSize(long nativeHandle, int width, int height);
 }
\ No newline at end of file
diff --git a/libvlc/src/org/videolan/libvlc/IAWindowNativeHandler.java b/libvlc/src/org/videolan/libvlc/IAWindowNativeHandler.java
index 15a765a..618c57c 100644
--- a/libvlc/src/org/videolan/libvlc/IAWindowNativeHandler.java
+++ b/libvlc/src/org/videolan/libvlc/IAWindowNativeHandler.java
@@ -94,4 +94,12 @@ public interface IAWindowNativeHandler {
      */
     @SuppressWarnings("unused") /* Used by JNI */
     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 */
+    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 f21b2bc..504d8c6 100644
--- a/libvlc/src/org/videolan/libvlc/IVLCVout.java
+++ b/libvlc/src/org/videolan/libvlc/IVLCVout.java
@@ -57,6 +57,12 @@ 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/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index a6b7514..2b4bf07 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -40,10 +40,6 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
     /** Native crash handler */
     private static OnNativeCrashListener sOnNativeCrashListener;
 
-    public interface HardwareAccelerationError {
-        void eventHardwareAccelerationError(); // TODO REMOVE
-    }
-
     /**
      * Create a LibVLC withs options
      *
@@ -92,11 +88,6 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
         this(null);
     }
 
-    public void setOnHardwareAccelerationError(HardwareAccelerationError error) {
-        nativeSetOnHardwareAccelerationError(error);
-    }
-    private native void nativeSetOnHardwareAccelerationError(HardwareAccelerationError error);
-
     /**
      * Get the libVLC version
      * @return the libVLC version string
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 72ad267..45cd7c1 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -540,6 +540,10 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         handleVout();
     }
 
+    @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/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 2a9537f..85b16b9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -132,7 +132,7 @@ import java.util.Date;
 import java.util.List;
 
 public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.Callback,
-        GestureDetector.OnDoubleTapListener, IDelayController, LibVLC.HardwareAccelerationError,
+        GestureDetector.OnDoubleTapListener, IDelayController,
         PlaybackService.Client.Callback, PlaybackService.Callback, PlaylistAdapter.IPlayer, OnClickListener, View.OnLongClickListener {
 
     public final static String TAG = "VLC/VideoPlayerActivity";
@@ -723,8 +723,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
         initUI();
 
-        LibVLC().setOnHardwareAccelerationError(this);
-
         loadMedia();
 
         // Add any selected subtitle file from the file picker
@@ -820,8 +818,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (mMute)
             mute(false);
 
-        LibVLC().setOnHardwareAccelerationError(null);
-
         mPlaybackStarted = false;
 
         mService.removeCallback(this);
@@ -1599,11 +1595,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mAlertDialog.show();
     }
 
-    @Override
-    public void eventHardwareAccelerationError() {
-        mHandler.sendEmptyMessage(HW_ERROR);
-    }
-
     private void handleHardwareAccelerationError() {
         mHardwareAccelerationError = true;
         if (mSwitchingView)
@@ -3187,6 +3178,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mSurfacesAttached = false;
     }
 
+    @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