Commit 21ca9ddb authored by Filippo Carone's avatar Filippo Carone

protect from null options param, and finalize added

parent fa096e60
...@@ -30,8 +30,11 @@ import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t; ...@@ -30,8 +30,11 @@ import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
public class VLM public class VLM
{ {
private JVLC jvlc; private JVLC jvlc;
private volatile boolean released;
public VLM(JVLC jvlc) public VLM(JVLC jvlc)
{ {
this.jvlc = jvlc; this.jvlc = jvlc;
...@@ -45,7 +48,7 @@ public class VLM ...@@ -45,7 +48,7 @@ public class VLM
name, name,
input, input,
output, output,
options.length, options == null ? 0 : options.length,
options, options,
enabled ? 1 : 0, enabled ? 1 : 0,
loop ? 1 : 0, loop ? 1 : 0,
...@@ -102,7 +105,7 @@ public class VLM ...@@ -102,7 +105,7 @@ public class VLM
name, name,
input, input,
output, output,
options.length, options == null ? 0 : options.length,
options, options,
enabled ? 1 : 0, enabled ? 1 : 0,
loop ? 1 : 0, loop ? 1 : 0,
...@@ -140,13 +143,29 @@ public class VLM ...@@ -140,13 +143,29 @@ public class VLM
} }
/** /**
* * Releases native resources related to VLM.
*/ */
public void release() public void release()
{ {
if (released)
{
return;
}
released = true;
libvlc_exception_t exception = new libvlc_exception_t(); libvlc_exception_t exception = new libvlc_exception_t();
jvlc.getLibvlc().libvlc_vlm_release(jvlc.getInstance(), exception); jvlc.getLibvlc().libvlc_vlm_release(jvlc.getInstance(), exception);
} }
/**
* {@inheritDoc}
*/
@Override
protected void finalize() throws Throwable
{
release();
super.finalize();
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment