[vlc-commits] medialibrary: Allow an event to be unregistered from its callback

Hugo Beauzée-Luyssen git at videolan.org
Mon Nov 12 17:12:27 CET 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Nov  8 16:51:33 2018 +0100| [1e3c6340763ec800ad9318cdcc9049df165ebeec] | committer: Hugo Beauzée-Luyssen

medialibrary: Allow an event to be unregistered from its callback

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

 include/vlc_media_library.h | 10 ++++++++++
 src/libvlccore.sym          |  1 +
 src/misc/medialibrary.c     |  8 ++++++++
 3 files changed, 19 insertions(+)

diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index 30079b0844..b6d65548f0 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -719,6 +719,16 @@ vlc_ml_event_register_callback( vlc_medialibrary_t* p_ml, vlc_ml_callback_t cb,
  */
 VLC_API void vlc_ml_event_unregister_callback( vlc_medialibrary_t* p_ml,
                                                vlc_ml_event_callback_t* p_callback );
+/**
+ * \brief Unregisters a medialibrary callback from the said callback.
+ * \param p_callback The handle returned by vlc_ml_register_callback
+ *
+ * This must only be called synchronously from the callback function provided to
+ * vlc_ml_event_register_callback
+ * The p_callback handle must be considered invalid when this function returns
+ */
+VLC_API void vlc_ml_event_unregister_from_callback( vlc_medialibrary_t* p_ml,
+                                                    vlc_ml_event_callback_t* p_callback );
 
 
 VLC_API void vlc_ml_show_release( vlc_ml_show_t* p_show );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index c87f11c69f..6c89bc65c0 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -599,6 +599,7 @@ vlc_ml_control
 vlc_ml_list
 vlc_ml_event_register_callback
 vlc_ml_event_unregister_callback
+vlc_ml_event_unregister_from_callback
 vlc_ml_show_release
 vlc_ml_artist_release
 vlc_ml_genre_release
diff --git a/src/misc/medialibrary.c b/src/misc/medialibrary.c
index a4d86d25b7..f84940e2c4 100644
--- a/src/misc/medialibrary.c
+++ b/src/misc/medialibrary.c
@@ -87,6 +87,14 @@ void vlc_ml_event_unregister_callback( vlc_medialibrary_t* p_ml,
     free( p_cb );
 }
 
+void vlc_ml_event_unregister_from_callback( vlc_medialibrary_t* p_ml,
+                                            vlc_ml_event_callback_t* p_cb )
+{
+    vlc_mutex_assert( &p_ml->lock );
+    vlc_list_remove( &p_cb->node );
+    free( p_cb );
+}
+
 static const vlc_medialibrary_callbacks_t callbacks = {
     .pf_send_event = &vlc_ml_event_send
 };



More information about the vlc-commits mailing list