Changeset eeb354fd028bd0294368108d3758bf8e86708857
- Timestamp:
- 04/07/08 00:01:58
(5 months ago)
- Author:
- Filippo Carone <littlejohn@videolan.org>
- git-committer:
- Filippo Carone <littlejohn@videolan.org> 1207519318 +0200
- git-parent:
[7b2e7a1a4d9802391c40867935e615c32689b556]
- git-author:
- Filippo Carone <littlejohn@videolan.org> 1207519301 +0200
- Message:
initial release method added to the JVLC class
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc71376b |
reeb354f |
|
| 46 | 46 | |
|---|
| 47 | 47 | private MediaList mediaList; |
|---|
| | 48 | |
|---|
| | 49 | private volatile boolean released; |
|---|
| 48 | 50 | |
|---|
| 49 | 51 | public JVLC() |
|---|
| … | … | |
| 126 | 128 | return libvlc; |
|---|
| 127 | 129 | } |
|---|
| | 130 | |
|---|
| | 131 | /** |
|---|
| | 132 | * Releases this instance and the native resources. |
|---|
| | 133 | */ |
|---|
| | 134 | public void release() |
|---|
| | 135 | { |
|---|
| | 136 | if (!released) |
|---|
| | 137 | { |
|---|
| | 138 | released = true; |
|---|
| | 139 | libvlc.libvlc_release(instance); |
|---|
| | 140 | } |
|---|
| | 141 | } |
|---|
| 128 | 142 | |
|---|
| 129 | 143 | /* |
|---|
| … | … | |
| 134 | 148 | protected void finalize() throws Throwable |
|---|
| 135 | 149 | { |
|---|
| 136 | | libvlc.libvlc_release(instance); |
|---|
| | 150 | if (!released) |
|---|
| | 151 | { |
|---|
| | 152 | released = true; |
|---|
| | 153 | libvlc.libvlc_release(instance); |
|---|
| | 154 | } |
|---|
| 137 | 155 | super.finalize(); |
|---|
| 138 | 156 | } |
|---|
| r5f584e4 |
reeb354f |
|
| 51 | 51 | } |
|---|
| 52 | 52 | |
|---|
| | 53 | @Test |
|---|
| | 54 | public void jvlcRelease() |
|---|
| | 55 | { |
|---|
| | 56 | JVLC jvlc = new JVLC(); |
|---|
| | 57 | jvlc.release(); |
|---|
| | 58 | jvlc.release(); |
|---|
| | 59 | } |
|---|
| 53 | 60 | |
|---|
| 54 | 61 | |
|---|
| rbf1292e |
reeb354f |
|
| 70 | 70 | Assert.assertNotNull(mediaListPlayer); |
|---|
| 71 | 71 | Assert.assertEquals(0, exception.raised); |
|---|
| | 72 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 72 | 73 | } |
|---|
| 73 | 74 | |
|---|
| … | … | |
| 80 | 81 | libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception); |
|---|
| 81 | 82 | Assert.assertEquals(0, exception.raised); |
|---|
| | 83 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| | 84 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 82 | 85 | } |
|---|
| 83 | 86 | |
|---|
| … | … | |
| 92 | 95 | libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList, exception); |
|---|
| 93 | 96 | Assert.assertEquals(0, exception.raised); |
|---|
| | 97 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| | 98 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 94 | 99 | } |
|---|
| 95 | 100 | |
|---|
| … | … | |
| 102 | 107 | Assert.assertEquals(0, result); |
|---|
| 103 | 108 | Assert.assertEquals(0, exception.raised); |
|---|
| | 109 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 104 | 110 | } |
|---|
| 105 | 111 | |
|---|
| … | … | |
| 111 | 117 | libvlc.libvlc_media_list_player_play(mediaListPlayer, exception); |
|---|
| 112 | 118 | Assert.assertEquals(1, exception.raised); |
|---|
| | 119 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 113 | 120 | } |
|---|
| 114 | 121 | |
|---|
| … | … | |
| 127 | 134 | libvlc.libvlc_media_list_player_play(mediaListPlayer, exception); |
|---|
| 128 | 135 | Assert.assertEquals("Exception message: " + exception.message + ".\n", 0, exception.raised); |
|---|
| | 136 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| | 137 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 129 | 138 | } |
|---|
| 130 | 139 | |
|---|
| … | … | |
| 153 | 162 | } |
|---|
| 154 | 163 | libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception); |
|---|
| | 164 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| | 165 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 155 | 166 | |
|---|
| 156 | 167 | } |
|---|
| … | … | |
| 184 | 195 | Thread.sleep(400); |
|---|
| 185 | 196 | libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception); |
|---|
| | 197 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| 186 | 198 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 187 | 199 | } |
|---|
| … | … | |
| 194 | 206 | int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer, exception); |
|---|
| 195 | 207 | Assert.assertEquals(LibVlcState.libvlc_Stopped.ordinal(), state); |
|---|
| | 208 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 196 | 209 | } |
|---|
| 197 | 210 | |
|---|
| … | … | |
| 237 | 250 | Assert.assertEquals("Expected state: " + LibVlcState.libvlc_Paused +".\n", LibVlcState.libvlc_Paused.ordinal(), state); |
|---|
| 238 | 251 | libvlc.libvlc_media_list_player_stop(mediaListPlayer, exception); |
|---|
| | 252 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| 239 | 253 | libvlc.libvlc_media_list_player_release(mediaListPlayer); |
|---|
| 240 | 254 | } |
|---|
| … | … | |
| 278 | 292 | libvlc.libvlc_media_list_player_next(mediaListPlayer, exception); |
|---|
| 279 | 293 | Assert.assertEquals(0, exception.raised); |
|---|
| | 294 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| 280 | 295 | } |
|---|
| 281 | 296 | |
|---|
| … | … | |
| 319 | 334 | mediaListPlayer, |
|---|
| 320 | 335 | exception)); |
|---|
| | 336 | libvlc.libvlc_media_list_release(mediaList); |
|---|
| 321 | 337 | } |
|---|
| 322 | 338 | |
|---|