[vlc-commits] lib: player: stop_async: return a status

Thomas Guillem git at videolan.org
Thu Nov 7 14:13:17 CET 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Nov  7 11:42:03 2019 +0100| [9fadde1bd4d4735e2652b90e4a478368743b7e17] | committer: Thomas Guillem

lib: player: stop_async: return a status

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

And improve the libvlc_media_player_stop_async documentation.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9fadde1bd4d4735e2652b90e4a478368743b7e17
---

 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 7cde2b2695..7c72c9774b 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 965cab2100..cdb6ba0b8c 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,



More information about the vlc-commits mailing list