]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
initial release method added to the JVLC class
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / JVLC.java
index e6c5be6640823709fe69f4567561bee3fd54d4c2..1d089c1566e4a96ba67d736a7f5190331c3a2da1 100644 (file)
@@ -46,6 +46,8 @@ public class JVLC
 
     private MediaList mediaList;
     
+    private volatile boolean released; 
+    
     public JVLC()
     {
         String[] args = new String[] {};
@@ -125,6 +127,18 @@ public class JVLC
     {
         return libvlc;
     }
+    
+    /**
+     * Releases this instance and the native resources.
+     */
+    public void release()
+    {
+        if (!released)
+        {
+            released = true;
+            libvlc.libvlc_release(instance);
+        }
+    }
 
     /*
      * (non-Javadoc)
@@ -133,7 +147,11 @@ public class JVLC
     @Override
     protected void finalize() throws Throwable
     {
-        libvlc.libvlc_release(instance);
+        if (!released)
+        {
+            released = true;
+            libvlc.libvlc_release(instance);
+        }
         super.finalize();
     }