[Android] LibVLC: load libraries from LibVLC constructor

Thomas Guillem git at videolan.org
Wed Feb 3 19:01:22 CET 2016


vlc-android | branch: dialog | Thomas Guillem <thomas at gllm.fr> | Wed Feb  3 16:28:22 2016 +0100| [e6fa3ba8618070d1f9513c2d7075e1d88f37f294] | committer: Thomas Guillem

LibVLC: load libraries from LibVLC constructor

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

 libvlc/src/org/videolan/libvlc/LibVLC.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index a712c06..4fb1253 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -50,6 +50,8 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
      * @param options
      */
     public LibVLC(ArrayList<String> options) {
+        loadLibraries();
+
         boolean setAout = true, setChroma = true;
         // check if aout/vout options are already set
         if (options != null) {
@@ -151,9 +153,14 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
     private native void nativeNew(String[] options);
     private native void nativeRelease();
     private native void nativeSetUserAgent(String name, String http);
+    
+    private static boolean sLoaded = false;
+
+    static synchronized void loadLibraries() {
+        if (sLoaded)
+            return;
+        sLoaded = true;
 
-    /* Load library before object instantiation */
-    static {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
             try {
                 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1)



More information about the Android mailing list