[vlc-devel] JVLC Crash when attaching Listeners

Filippo Carone filippo at carone.org
Sat Jan 10 00:11:27 CET 2009

Joseph Neubauer ha scritto:
> Hi!
> I'm new to VLC especially to JVLC.
> For a project I tried out JVLC and started with the example code 
> (VLCExample) and experienced crashes when attaching a listener and play 
> multiple files with the same JVLC instance or pushing pause/play/stop often.
> ...
> the "old" MediaPlayer object is no longer valid but not destroyed, 
> because the call to finalize() (where the callbacks are detached) is 
> controlled by Java-VM and the time it is called must not be the time the 
> object is destroyed. So the event manager may call a null (or no longer 
> valid) pointer, because the callbacks are not detached.
> For a first attempt I made the field mediaPlayer in MediaDescriptor
> static an added new methods shutdown() and newDescriptor(...) to
> MediaPlayer.
> ...
> Unfortunately, due to the static field, there can be only one
> MediaPlayer in one JVLC instance. I will try to change this.

Hi Joseph,
 you are right, there's no way to control the way the jvm finalizes
objects. On the other hand, having a static field is, as you state later
in the email, bad.

 I'm going to add a release() method to every JVLC object, in order to
let the coder release native resources tied to java object instances.
Once a object is released, accessing it will cause a RuntimeException
(or subclass of it).

 What do you think about this approach?


More information about the vlc-devel mailing list