[vlc-devel] [PATCH 2/3] Export libvlc_media_list_remove_all

Edward Wang edward.c.wang at compdigitec.com
Wed Jan 11 01:12:17 CET 2012


---
 include/vlc/libvlc_media_list.h |    9 +++++++++
 lib/libvlc.sym                  |    1 +
 lib/media_list.c                |   15 +++++++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/vlc/libvlc_media_list.h b/include/vlc/libvlc_media_list.h
index 015824b..dcf3176 100644
--- a/include/vlc/libvlc_media_list.h
+++ b/include/vlc/libvlc_media_list.h
@@ -128,6 +128,15 @@ LIBVLC_API int
 libvlc_media_list_remove_index( libvlc_media_list_t *p_ml, int i_pos );
 
 /**
+ * Remove all media instances from media list on a position
+ *
+ * \param p_ml a media list instance
+ * \return 0 on success, -1 if the list is read-only
+ */
+LIBVLC_API int
+libvlc_media_list_remove_all( libvlc_media_list_t * p_mlist );
+
+/**
  * Get count on media list items
  * The libvlc_media_list_lock should be held upon entering this function.
  *
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 45327d5..45b4d54 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -102,6 +102,7 @@ libvlc_media_list_player_set_media_player
 libvlc_media_list_player_set_playback_mode
 libvlc_media_list_player_stop
 libvlc_media_list_release
+libvlc_media_list_remove_all
 libvlc_media_list_remove_index
 libvlc_media_list_retain
 libvlc_media_list_set_media
diff --git a/lib/media_list.c b/lib/media_list.c
index 749d3c5..70e9de9 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -393,6 +393,21 @@ int libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
     return _libvlc_media_list_remove_index( p_mlist, index );
 }
 
+/**************************************************************************
+ *       libvlc_media_list_remove_all (Public)
+ **************************************************************************/
+int libvlc_media_list_remove_all( libvlc_media_list_t * p_mlist )
+{
+    if( !mlist_is_writable(p_mlist) )
+        return -1;
+    vlc_mutex_lock( &p_mlist->object_lock );
+    for( int i = 0; i < libvlc_media_list_count( p_mlist ); i++ ) {
+        _libvlc_media_list_remove_index( p_mlist, i );
+    }
+    vlc_mutex_unlock( &p_mlist->object_lock );
+    return 0;
+}
+
 /* LibVLC internal version */
 int _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
                                      int index )
-- 
1.7.5.4




More information about the vlc-devel mailing list