<html><head></head><body>Hi,<br><br>This looks like it'll dead lock if more than one thread calls the stop. Not sure if that worked in the current code or not.<br><br><div class="gmail_quote">Le 15 mai 2019 12:53:16 GMT+03:00, Romain Vimont <rom1v@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">To preserve the old behavior, make libvlc_media_player_stop()<br>synchronous.<hr> lib/media_player.c | 13 ++++++++++++-<br> lib/media_player_internal.h | 3 +++<br> 2 files changed, 15 insertions(+), 1 deletion(-)<br><br>diff --git a/lib/media_player.c b/lib/media_player.c<br>index 17d675e93b..e5f6fc32a7 100644<br>--- a/lib/media_player.c<br>+++ b/lib/media_player.c<br>@@ -108,6 +108,8 @@ on_state_changed(vlc_player_t *player, enum vlc_player_state new_state,<br> switch (new_state) {<br> case VLC_PLAYER_STATE_STOPPED:<br> event.type = libvlc_MediaPlayerStopped;<br>+ if (mp->stop_requested)<br>+ vlc_sem_post(&mp->sem_stop);<br> break;<br> case VLC_PLAYER_STATE_STOPPING:<br> event.type = libvlc_MediaPlayerEndReached;<br>@@ -715,6 +717,9 @@ libvlc_media_player_new( libvlc_instance_t *instance )<br> <br> vlc_player_Unlock(mp->player);<br> <br>+ vlc_sem_init(&mp->sem_stop, 0);<br>+ mp->stop_requested = false;<br>+<br> mp->i_refcount = 1;<br> libvlc_event_manager_init(&mp->event_manager, mp);<br> <br>@@ -796,6 +801,8 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )<br> libvlc_event_manager_destroy(&p_mi->event_manager);<br> libvlc_media_release( p_mi->p_md );<br> <br>+ vlc_sem_destroy(&p_mi->sem_stop);<br>+<br> vlc_http_cookie_jar_t *cookies = var_GetAddress( p_mi, "http-cookies" );<br> if ( cookies )<br> {<br>@@ -972,9 +979,13 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi )<br> vlc_player_t *player = p_mi->player;<br> vlc_player_Lock(player);<br> <br>- vlc_player_Stop(player);<br>+ bool stop_async = vlc_player_Stop(player);<br>+ p_mi->stop_requested = stop_async;<br> <br> vlc_player_Unlock(player);<br>+<br>+ if (stop_async)<br>+ vlc_sem_wait(&p_mi->sem_stop);<br> }<br> <br> int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,<br>diff --git a/lib/media_player_internal.h b/lib/media_player_internal.h<br>index c2d5348e22..a0c712780d 100644<br>--- a/lib/media_player_internal.h<br>+++ b/lib/media_player_internal.h<br>@@ -49,6 +49,9 @@ struct libvlc_media_player_t<br> struct libvlc_instance_t * p_libvlc_instance; /* Parent instance */<br> libvlc_media_t * p_md; /* current media descriptor */<br> libvlc_event_manager_t event_manager;<br>+<br>+ vlc_sem_t sem_stop;<br>+ bool stop_requested;<br> };<br> <br> libvlc_track_description_t * libvlc_get_track_description(</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>