Commit eeb354fd authored by Filippo Carone's avatar Filippo Carone

initial release method added to the JVLC class

parent 7b2e7a1a
......@@ -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();
}
......
......@@ -50,6 +50,13 @@ public class JVLCTest
Assert.assertNotNull(instance);
}
@Test
public void jvlcRelease()
{
JVLC jvlc = new JVLC();
jvlc.release();
jvlc.release();
}
}
......@@ -69,6 +69,7 @@ public class MediaListPlayerTest
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
Assert.assertNotNull(mediaListPlayer);
Assert.assertEquals(0, exception.raised);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -79,6 +80,8 @@ public class MediaListPlayerTest
LibVlcMediaList mediaList = libvlc.libvlc_media_list_new(libvlcInstance, exception);
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
Assert.assertEquals(0, exception.raised);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -91,6 +94,8 @@ public class MediaListPlayerTest
libvlc.libvlc_media_list_add_media(mediaList, mediaDescriptor, exception);
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
Assert.assertEquals(0, exception.raised);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -101,6 +106,7 @@ public class MediaListPlayerTest
int result = libvlc.libvlc_media_list_player_is_playing(mediaListPlayer, exception);
Assert.assertEquals(0, result);
Assert.assertEquals(0, exception.raised);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -110,6 +116,7 @@ public class MediaListPlayerTest
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
libvlc.libvlc_media_list_player_play(mediaListPlayer, exception);
Assert.assertEquals(1, exception.raised);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
/**
......@@ -126,6 +133,8 @@ public class MediaListPlayerTest
libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception);
libvlc.libvlc_media_list_player_play(mediaListPlayer, exception);
Assert.assertEquals("Exception message: " + exception.message + ".\n", 0, exception.raised);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -152,6 +161,8 @@ public class MediaListPlayerTest
Thread.sleep(150);
}
libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
......@@ -183,6 +194,7 @@ public class MediaListPlayerTest
// needs to be fixed
Thread.sleep(400);
libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
......@@ -193,6 +205,7 @@ public class MediaListPlayerTest
LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance, exception);
int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception);
Assert.assertEquals(LibVlcState.libvlc_Stopped.ordinal(), state);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
@Test
......@@ -236,6 +249,7 @@ public class MediaListPlayerTest
int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception);
Assert.assertEquals("Expected state: " + LibVlcState.libvlc_Paused +".\n", LibVlcState.libvlc_Paused.ordinal(), state);
libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception);
libvlc.libvlc_media_list_release(mediaList);
libvlc.libvlc_media_list_player_release(mediaListPlayer);
}
......@@ -277,6 +291,7 @@ public class MediaListPlayerTest
Thread.sleep(150);
libvlc.libvlc_media_list_player_next(mediaListPlayer, exception);
Assert.assertEquals(0, exception.raised);
libvlc.libvlc_media_list_release(mediaList);
}
@Test
......@@ -318,6 +333,7 @@ public class MediaListPlayerTest
Assert.assertEquals(LibVlcState.libvlc_Stopped.ordinal(), libvlc.libvlc_media_list_player_get_state(
mediaListPlayer,
exception));
libvlc.libvlc_media_list_release(mediaList);
}
......
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