[vlc-devel] Deadlock on stop

Romain Vimont | ®om rom at rom1v.com
Fri Apr 25 16:38:11 CEST 2014

A very simple piece of Java code (to be executed from an Activity) to
reproduce the deadlock with an acceptable probability:

    public void test() {
        MediaList playlist = libvlc.getPrimaryMediaList();
        playlist.add(new Media(libvlc, myUdpMulticastUrl));
        new Handler().post(new Runnable() {
            public void run() {

When it works, then the video is stopped. When it deadlocks, it is
blocked on vlc_sem_wait().

You should be able to multicast any file from your desktop:

    cvlc video.mkv ':sout=#udp{dst=}'

On the Android device, replace myUdpMulticastUrl by


Le vendredi 25 avril 2014 à 15:13 +0200, Romain Vimont | ®om a écrit :
> Hi,
> I use libvlc in an Android application, and I experience a deadlock:
> libvlc.stop() does never return in some cases.
> I investigated a little, and found what is blocking when calling
> libvlc_media_player_stop(…). Here is the stack of calls:
>  - release_input_thread( p_mi, true );
>    - input_Close( p_input_thread );
>      - input_Join( p_input );
>        - vlc_join( p_input->p->thread, NULL );
>          - vlc_sem_wait (&handle->finished);  // block forever
> This does not always happen, but only when I am already playing a video,
> and try to play and stop nearly simultaneously (I stop playing by
> pressing a key and start from a remote control at the same time), so it
> seems there is a race condition.
> Also, I reproduce it about ~25% using a UDP multicast stream
> (udp://@, but I can't reproduce if I use an HTTP stream,
> the very same UDP stream proxyfied by udpxy
> (http://<udpxy>/udp/
> http://www.udpxy.com/index-en.html
> I guess there should be a call to vlc_sem_post() somewhere to wake it
> up… Maybe you have an idea?
> Regards,
> PS: my VLC versions:
> git://git.videolan.org/vlc.git (3b7bfa1)
> git://git.videolan.org/vlc-ports/android.git (995ac44)

More information about the vlc-devel mailing list