[vlc-devel] [PATCH 2/2] lib: player: stop_async: return a status

Thomas Guillem thomas at gllm.fr
Thu Nov 7 11:42:30 CET 2019


In order to notify the user if he should wait for the stopped event.

And improve the libvlc_media_player_stop_async documentation.
---
 include/vlc/libvlc_media_player.h | 10 ++++++++--
 lib/media_player.c                |  6 ++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 7cde2b26952..7c72c9774b2 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -268,11 +268,17 @@ 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 asynchronously
+ *
+ * \note This function is asynchronous. In case of success, the user should
+ * wait for the libvlc_MediaPlayerStopped event to know when the stop is
+ * finished.
  *
  * \param p_mi the Media Player
+ * \return 0 if the player is being stopped, -1 otherwise (no-op)
+ * \version LibVLC 4.0.0 or later
  */
-LIBVLC_API void libvlc_media_player_stop_async ( libvlc_media_player_t *p_mi );
+LIBVLC_API int 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 965cab2100a..cdb6ba0b8c5 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -974,14 +974,16 @@ bool 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 )
+int 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);
+    int ret = vlc_player_Stop(player);
 
     vlc_player_Unlock(player);
+
+    return ret;
 }
 
 int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,
-- 
2.20.1



More information about the vlc-devel mailing list