<html><head></head><body>Hi,<br><br>I don't see the point in adding a parameter here. If you want to use libpulse-like semantics, just make the lock recursive.<br><br>But in any case, this won't provide backward compatibility.<br><br><div class="gmail_quote">Le 13 mai 2019 15:47:36 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">This will allow to implement the old libvlc API using the new player.<br><br><<a href="https://mailman.videolan.org/pipermail/vlc-devel/2019-May/124461.html">https://mailman.videolan.org/pipermail/vlc-devel/2019-May/124461.html</a>><hr> include/vlc_player.h | 25 ++++++++++++++++++++++++-<br> src/input/player.c | 12 ++++++++----<br> src/playlist/player.c | 3 ++-<br> 3 files changed, 34 insertions(+), 6 deletions(-)<br><br>diff --git a/include/vlc_player.h b/include/vlc_player.h<br>index 1aa5f8e687..d4c49fa89d 100644<br>--- a/include/vlc_player.h<br>+++ b/include/vlc_player.h<br>@@ -331,6 +331,29 @@ enum vlc_player_subtitle_sync<br> VLC_PLAYER_SUBTITLE_SYNC_APPLY,<br> };<br> <br>+/**<br>+ * Player lock type (normal or reentrant)<br>+ */<br>+enum vlc_player_lock_type<br>+{<br>+ /**<br>+ * Normal lock<br>+ *<br>+ * If the player is already locked, subsequent calls to vlc_player_Lock()<br>+ * will deadlock.<br>+ */<br>+ VLC_PLAYER_LOCK_NORMAL,<br>+<br>+ /**<br>+ * Reentrant lock<br>+ *<br>+ * If the player is already locked, subsequent calls to vlc_player_Lock()<br>+ * will still succeed. To unlock the player, one call to<br>+ * vlc_player_Unlock() per vlc_player_Lock() is necessary.<br>+ */<br>+ VLC_PLAYER_LOCK_REENTRANT,<br>+};<br>+<br> /** Player capability: can seek */<br> #define VLC_PLAYER_CAP_SEEK (1<<0)<br> /** Player capability: can pause */<br>@@ -1005,7 +1028,7 @@ vlc_player_title_list_GetAt(vlc_player_title_list *titles, size_t idx);<br> * @return a pointer to a valid player instance or NULL in case of error<br> */<br> VLC_API vlc_player_t *<br>-vlc_player_New(vlc_object_t *parent,<br>+vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,<br> const struct vlc_player_media_provider *media_provider,<br> void *media_provider_data);<br> <br>diff --git a/src/input/player.c b/src/input/player.c<br>index da02375a66..e01701ba65 100644<br>--- a/src/input/player.c<br>+++ b/src/input/player.c<br>@@ -3367,9 +3367,13 @@ vlc_player_vout_Snapshot(vlc_player_t *player)<br> }<br> <br> static void<br>-vlc_player_InitLocks(vlc_player_t *player)<br>+vlc_player_InitLocks(vlc_player_t *player, enum vlc_player_lock_type lock_type)<br> {<br>- vlc_mutex_init(&player->lock);<br>+ if (lock_type == VLC_PLAYER_LOCK_REENTRANT)<br>+ vlc_mutex_init_recursive(&player->lock);<br>+ else<br>+ vlc_mutex_init(&player->lock);<br>+<br> vlc_mutex_init(&player->vout_listeners_lock);<br> vlc_mutex_init(&player->aout_listeners_lock);<br> vlc_cond_init(&player->start_delay_cond);<br>@@ -3426,7 +3430,7 @@ vlc_player_Delete(vlc_player_t *player)<br> }<br> <br> vlc_player_t *<br>-vlc_player_New(vlc_object_t *parent,<br>+vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,<br> const struct vlc_player_media_provider *media_provider,<br> void *media_provider_data)<br> {<br>@@ -3514,7 +3518,7 @@ vlc_player_New(vlc_object_t *parent,<br> }<br> <br> player->deleting = false;<br>- vlc_player_InitLocks(player);<br>+ vlc_player_InitLocks(player, lock_type);<br> <br> if (vlc_clone(&player->destructor.thread, vlc_player_destructor_Thread,<br> player, VLC_THREAD_PRIORITY_LOW) != 0)<br>diff --git a/src/playlist/player.c b/src/playlist/player.c<br>index bbdc39ba0e..8e3d94e2e8 100644<br>--- a/src/playlist/player.c<br>+++ b/src/playlist/player.c<br>@@ -123,7 +123,8 @@ static const struct vlc_player_cbs player_callbacks = {<br> bool<br> vlc_playlist_PlayerInit(vlc_playlist_t *playlist, vlc_object_t *parent)<br> {<br>- playlist->player = vlc_player_New(parent, &player_media_provider, playlist);<br>+ playlist->player = vlc_player_New(parent, VLC_PLAYER_LOCK_NORMAL,<br>+ &player_media_provider, playlist);<br> if (unlikely(!playlist->player))<br> return false;<br> </pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>