<html><head></head><body>Hi,<br><br>It is possible with proprietary attributes, and we already have examples, but not with standard C/C++.<br><br>I think you can just remove the function though. Nowadays most compilers and IDE can suggest close identifier matches.<br><br><div class="gmail_quote">Le 17 mai 2019 21:22:03 GMT+03:00, Thomas Guillem <thomas@gllm.fr> 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"><br><br>On Fri, May 17, 2019, at 11:32, Steve Lhomme wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">On 2019-05-17 10:58, Romain Vimont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">On Wed, May 15, 2019 at 01:31:14PM +0300, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> 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></blockquote>Yes, this is incorrect in that case.<br><br>But since the callbacks are called with player locked, we necessarily<br>need to unlock the player one way or another to wait for the "stopped"<br>event.<br><br>An alternative is to use a condition variable with the player mutex:<br><br>     vlc_player_Lock(player);<br>     bool stop_async = vlc_player_Stop(player);<br>     if (stop_async)<br>          vlc_player_CondWait(player, &p_mi->cond_stop);<br>     vlc_player_Unlock(player);<br><br>But this is still not correct, because others vlc_player_Start() and<br>vlc_player_Stop() can be executed during vlc_player_CondWait().<br><br>The problem is that we can't associate a specific stop request with the<br>right "player state change to stopped", so we would wake up all threads<br>waiting for stop on the first "state change to stopped".<br><br>Since we don't want synchronous stop anymore (it was just for backward<br>compatibility), I suggest we just make libvlc_media_player_stop()<br>asynchronous.<br><br>And we document breaking changes from libvlc 3 to libvlc 4:<br>- libvlc_media_player_will_play() is removed (it is meaningless with the<br>   new player)<br>- libvlc_media_player callbacks are called with the same (recursive)<br>   mutex as libvlc_media_player functions<br>- libvlc_media_player_stop is now asynchronous (it was the only blocking<br>   function, it does not block anymore)<br></blockquote>IMO it's better to use a different name. You don't want old code to use <br>the new behaviour incorrectly. Unless the signature of the function is <br>different, then it shouldn't compile (but will wrappers in other <br>languages notice?). IMO just remove the old behaviour and use a new name.<br></blockquote><br> +1<br>Remove stop and add stop_async.<br><br>Is it possible with some macros to trigger an "#error use the stop_async version" ?<br><br>> <br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;">Le 15 mai 2019 12:53:16 GMT+03:00, Romain Vimont <rom1v@videolabs.io> a écrit :<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #fcaf3e; padding-left: 1ex;"> 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<br> 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<br> *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(<br> 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> );<br>      if ( cookies )<br>      {<br> @@ -972,9 +979,13 @@ void libvlc_media_player_stop(<br> 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(<br> -- <br> 2.20.1<hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.<br><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>