[vlc-devel] [PATCH v2 9/9] libvlc: player: add stop_async()
Romain Vimont
rom1v at videolabs.io
Wed May 15 11:53:17 CEST 2019
libvlc_media_player_stop() was the only blocking function, the others
(play, pauseā¦) were asynchronous.
Add a function which stop asynchronously.
---
include/vlc/libvlc_media_player.h | 12 +++++++++++-
lib/media_player.c | 10 ++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 3fc0b6a644..363d3f21f4 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -267,12 +267,22 @@ LIBVLC_API void libvlc_media_player_set_pause ( libvlc_media_player_t *mp,
LIBVLC_API void libvlc_media_player_pause ( libvlc_media_player_t *p_mi );
/**
- * Stop (no effect if there is no media)
+ * Stop synchronously (no effect if there is no media)
+ *
+ * This function blocks until the input thread is actually stopped.
+ * Prefer libvlc_media_player_stop_async().
*
* \param p_mi the Media Player
*/
LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
+/**
+ * Stop (no effect if there is no media)
+ *
+ * \param p_mi the Media Player
+ */
+LIBVLC_API void libvlc_media_player_stop_async ( libvlc_media_player_t *p_mi );
+
/**
* Set a renderer to the media player
*
diff --git a/lib/media_player.c b/lib/media_player.c
index e5f6fc32a7..33d863f48d 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -974,6 +974,16 @@ int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi )
/**************************************************************************
* Stop playing.
**************************************************************************/
+void libvlc_media_player_stop_async( libvlc_media_player_t *p_mi )
+{
+ vlc_player_t *player = p_mi->player;
+ vlc_player_Lock(player);
+
+ vlc_player_Stop(player);
+
+ vlc_player_Unlock(player);
+}
+
void libvlc_media_player_stop( libvlc_media_player_t *p_mi )
{
vlc_player_t *player = p_mi->player;
--
2.20.1
More information about the vlc-devel
mailing list