]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/VLM.java
protect from null options param, and finalize added
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / VLM.java
index 23a53452e5a15a46749be40723cb385c2228cdd2..7763726fb437889f0a6cb1ce41c51471c9adca37 100644 (file)
@@ -32,6 +32,8 @@ public class VLM
 {
 
     private JVLC jvlc;
+    
+    private volatile boolean released;
 
     public VLM(JVLC jvlc)
     {
@@ -46,7 +48,7 @@ public class VLM
             name,
             input,
             output,
-            options.length,
+            options == null ? 0 : options.length,
             options,
             enabled ? 1 : 0,
             loop ? 1 : 0,
@@ -103,7 +105,7 @@ public class VLM
             name,
             input,
             output,
-            options.length,
+            options == null ? 0 : options.length,
             options,
             enabled ? 1 : 0,
             loop ? 1 : 0,
@@ -115,13 +117,13 @@ public class VLM
         libvlc_exception_t exception = new libvlc_exception_t();
         jvlc.getLibvlc().libvlc_vlm_play_media(jvlc.getInstance(), name, exception);
     }
-    
+
     public void stopMedia(String name)
     {
         libvlc_exception_t exception = new libvlc_exception_t();
         jvlc.getLibvlc().libvlc_vlm_stop_media(jvlc.getInstance(), name, exception);
     }
-    
+
     public void pauseMedia(String name)
     {
         libvlc_exception_t exception = new libvlc_exception_t();
@@ -140,5 +142,30 @@ public class VLM
         jvlc.getLibvlc().libvlc_vlm_show_media(jvlc.getInstance(), name, exception);
     }
 
+    /**
+     * Releases native resources related to VLM.
+     */
+    public void release()
+    {
+        if (released)
+        {
+            return;
+        }
+        released = true;
+        libvlc_exception_t exception = new libvlc_exception_t();
+        jvlc.getLibvlc().libvlc_vlm_release(jvlc.getInstance(), exception);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void finalize() throws Throwable
+    {
+        release();
+        super.finalize();
+    }
+    
     
+
 }