]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
VLM class almost done
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / JVLC.java
index e6c5be6640823709fe69f4567561bee3fd54d4c2..32cf17988873986865e52b2ea76acc9956b4e2b0 100644 (file)
@@ -46,6 +46,10 @@ public class JVLC
 
     private MediaList mediaList;
     
+    private VLM vlm;
+    
+    private volatile boolean released; 
+    
     public JVLC()
     {
         String[] args = new String[] {};
@@ -94,6 +98,16 @@ public class JVLC
         return new Logger(this);
     }
     
+    public VLM getVLM()
+    {
+        if (vlm != null)
+        {
+            vlm.release();
+        }
+        this.vlm = new VLM(this);
+        return vlm;
+    }
+    
     public LoggerVerbosityLevel getLogVerbosity()
     {
         libvlc_exception_t exception = new libvlc_exception_t();
@@ -125,6 +139,23 @@ public class JVLC
     {
         return libvlc;
     }
+    
+    /**
+     * Releases this instance and the native resources.
+     */
+    public void release()
+    {
+        if (!released)
+        {
+            released = true;
+            if (vlm != null)
+            {
+                vlm.release();
+                vlm = null;
+            }
+            libvlc.libvlc_release(instance);
+        }
+    }
 
     /*
      * (non-Javadoc)
@@ -133,7 +164,11 @@ public class JVLC
     @Override
     protected void finalize() throws Throwable
     {
-        libvlc.libvlc_release(instance);
+        if (!released)
+        {
+            released = true;
+            libvlc.libvlc_release(instance);
+        }
         super.finalize();
     }