]> git.sesse.net Git - vlc/blobdiff - src/control/flat_media_list_view.c
libvlc_media_player: fix object leak (input thread).
[vlc] / src / control / flat_media_list_view.c
index d6fc8bfc54fc8a9f38016a9e34a1564eb17c3f0e..e5f51401d62cb2f3e00b4977a1793ed208674524 100644 (file)
@@ -2,7 +2,7 @@
  * flat_media_list_view.c: libvlc flat media list view functions.
  *****************************************************************************
  * Copyright (C) 2007 the VideoLAN team
- * $Id: flat_media_list.c 21287 2007-08-20 01:28:12Z pdherbemont $
+ * $Id$
  *
  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  *
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include "libvlc_internal.h"
-#include <vlc/libvlc.h>
 #include <assert.h>
-#include "vlc_arrays.h"
+
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_media.h>
+#include <vlc/libvlc_media_list.h>
+#include <vlc/libvlc_media_list_view.h>
+
+#include "media_list_view_internal.h"
+
 
 //#define DEBUG_FLAT_VIEW
 
@@ -50,8 +55,10 @@ static void
 ml_item_added( const libvlc_event_t * p_event, libvlc_media_list_view_t * p_mlv )
 {
     int index = vlc_array_count( &p_mlv->p_this_view_data->array );
-    libvlc_media_descriptor_t * p_md = p_event->u.media_list_item_added.item;
-    libvlc_media_descriptor_retain( p_md );
+    libvlc_media_t * p_md = p_event->u.media_list_item_added.item;
+    libvlc_media_retain( p_md );
+    trace("appending item at index %d\n", index);
+
     libvlc_media_list_view_will_add_item( p_mlv, p_md, index );
     vlc_array_append( &p_mlv->p_this_view_data->array, p_md );
     libvlc_media_list_view_item_added( p_mlv, p_md, index );
@@ -63,14 +70,14 @@ ml_item_added( const libvlc_event_t * p_event, libvlc_media_list_view_t * p_mlv
 static void
 ml_item_removed( const libvlc_event_t * p_event, libvlc_media_list_view_t * p_mlv )
 {
-    libvlc_media_descriptor_t * p_md = p_event->u.media_list_item_deleted.item;
+    libvlc_media_t * p_md = p_event->u.media_list_item_deleted.item;
     int i = vlc_array_index_of_item( &p_mlv->p_this_view_data->array, p_md );
     if( i >= 0 )
     {
         libvlc_media_list_view_will_delete_item( p_mlv, p_md, i );
         vlc_array_remove( &p_mlv->p_this_view_data->array, i );
         libvlc_media_list_view_item_deleted( p_mlv, p_md, i );
-        libvlc_media_descriptor_release( p_md );
+        libvlc_media_release( p_md );
     }
 }
 
@@ -90,15 +97,15 @@ flat_media_list_view_count( libvlc_media_list_view_t * p_mlv,
  *       flat_media_list_view_item_at_index  (private)
  * (called by flat_media_list_view_item_at_index)
  **************************************************************************/
-static libvlc_media_descriptor_t *
+static libvlc_media_t *
 flat_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv,
                                     int index,
                                     libvlc_exception_t * p_e )
 {
-    libvlc_media_descriptor_t * p_md;
+    libvlc_media_t * p_md;
     (void)p_e;
     p_md = vlc_array_item_at_index( &p_mlv->p_this_view_data->array, index );
-    libvlc_media_descriptor_retain( p_md );
+    libvlc_media_retain( p_md );
     return p_md;
 }
 
@@ -111,6 +118,7 @@ flat_media_list_view_children_at_index( libvlc_media_list_view_t * p_mlv,
                                         int index,
                                         libvlc_exception_t * p_e )
 {
+    (void)p_mlv; (void)index; (void)p_e;
     return NULL;
 }
 
@@ -139,11 +147,11 @@ import_mlist_rec( libvlc_media_list_view_t * p_mlv,
     count = libvlc_media_list_count( p_mlist, p_e );
     for( i = 0; i < count; i++ )
     {
-        libvlc_media_descriptor_t * p_md;
+        libvlc_media_t * p_md;
         libvlc_media_list_t * p_submlist;
         p_md = libvlc_media_list_item_at_index( p_mlist, i, p_e );
         vlc_array_append( &p_mlv->p_this_view_data->array, p_md );
-        p_submlist = libvlc_media_descriptor_subitems( p_md, p_e );
+        p_submlist = libvlc_media_subitems( p_md, p_e );
         if( p_submlist )
         {
             libvlc_media_list_lock( p_submlist );
@@ -172,6 +180,7 @@ libvlc_media_list_flat_view( libvlc_media_list_t * p_mlist,
                                         flat_media_list_view_count,
                                         flat_media_list_view_item_at_index,
                                         flat_media_list_view_children_at_index,
+                                        libvlc_media_list_flat_view,
                                         flat_media_list_view_release,
                                         p_this_view_data,
                                         p_e );