[vlc-devel] JVLC Crash when attaching Listeners

Joseph Neubauer jneubauer at gmx.de
Fri Jan 9 17:12:55 CET 2009


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.

I think, the crashes occur in the event manager of libvlc. I decided to 
get the JVLC source via git and try to fix the problem.
I now suppose the problem lies withing MediaPlayer.java, which is always 
created new when calling MediaDescriptor.getMediaPlayer. At this time 
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. The method getMediaPlayer() in MediaDescriptor now returns 
a previous created MediaPlayer and calls newDescriptor or creates a new one.
The method newDescriptor(...) calls the shutdown()-method, which 
detaches all attached callbacks first before getting a new instance and 
a new event manager from libVLC.
This solves the described problem.
Unfortunately, due to the static field, there can be only one 
MediaPlayer in one JVLC instance. I will try to change this.

My question now: Should I commit my version of JVLC? Is it of interest? 
If I should post any code, to whom should I post it?


Thanks! Greetings,
Joseph Neubauer



More information about the vlc-devel mailing list