[vlc-devel] commit: initial release method added to the JVLC class (Filippo Carone )
git version control
git at videolan.org
Mon Apr 7 00:01:13 CEST 2008
vlc | branch: master | Filippo Carone <littlejohn at videolan.org> | Mon Apr 7 00:01:41 2008 +0200| [eeb354fd028bd0294368108d3758bf8e86708857]
initial release method added to the JVLC class
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eeb354fd028bd0294368108d3758bf8e86708857
---
.../core/src/main/java/org/videolan/jvlc/JVLC.java | 20 +++++++++++++++++++-
.../src/test/java/org/videolan/jvlc/JVLCTest.java | 7 +++++++
.../jvlc/internal/MediaListPlayerTest.java | 16 ++++++++++++++++
3 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java b/bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
index e6c5be6..1d089c1 100644
--- a/bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
+++ b/bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
@@ -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();
}
diff --git a/bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java b/bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
index 64810c3..17ec661 100644
--- a/bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
+++ b/bindings/java/core/src/test/java/org/videolan/jvlc/JVLCTest.java
@@ -50,6 +50,13 @@ public class JVLCTest
Assert.assertNotNull(instance);
}
+ @Test
+ public void jvlcRelease()
+ {
+ JVLC jvlc = new JVLC();
+ jvlc.release();
+ jvlc.release();
+ }
}
diff --git a/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListPlayerTest.java b/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListPlayerTest.java
index 4061e6e..5baf02b 100644
--- a/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListPlayerTest.java
+++ b/bindings/java/core/src/test/java/org/videolan/jvlc/internal/MediaListPlayerTest.java
@@ -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);
}
More information about the vlc-devel
mailing list