[vlc-devel] [PATCH 3.x 0/2] RFC: libvlc_media_player: add async stop

Thomas Guillem thomas at gllm.fr
Mon Oct 19 16:48:16 CEST 2020



On Mon, Oct 19, 2020, at 16:29, Rémi Denis-Courmont wrote:
> Le maanantaina 19. lokakuuta 2020, 17.07.35 EEST Thomas Guillem a écrit :
> > I don't think the current libvlc_media_player_stop() is usable since it
> > is blocking. VLC ports usually call it from background threads, but it
> > lead to deadlocks when the mainthread is calling libvlc_media_player getter
> > functions.
> 
> liblvc_media_player_stop() is inconvenient for sure, but I don't exactly 
> follow how it would be unusable.

Indeed, inconvenient is a better word for that situation.

> From what I have seen, deadlocks are usually 
> caused by threading mistakes in applications. In particular, if there is a 
> deadlock, how come libvlc_media_player_release() is not exhibiting the same 
> problem?

libvlc_media_player_release() will block but not deadlock since there should not be any users interaction when it's called.
By the way, I don't like the fact that it is refcounted since the user can't know if the call will block or not.
Ideally, libvlc and mediaplayer should be destroyed after the UI is destroyed.
> 
> If it's really necessary to update LibVLC 3.x, then that's that, but you're a 
> bit light on details here, IMO.

Here is an example of deadlock https://code.videolan.org/-/snippets/1286/raw

1/ libvlc_media_list_player_play_item_at_index() that will call input_Close() is called from a background thread (as a hack, since it is a blocking call).
2/ The setting of the new media cause the ios vout to wait for the mainthread.
3/ libvlc_video_get_track_count() is called from the mainthread and wait for the input_thread that is closing.

 => Deadlock.

The point 2 is debatable, maybe we should fix the ios vout to not wait for the mainthread.

Anyway, the current situation forbid LibVLC users to set new media from the mainthread, that is why a background thread is used for 1/.


> 
> -- 
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list