]> git.sesse.net Git - vlc/blobdiff - projects/macosx/framework/Sources/VLCMediaList.m
use NSAutoreleasePool::drain instead of NSAutoreleasePool::release since VLCKit ist...
[vlc] / projects / macosx / framework / Sources / VLCMediaList.m
index f9ed8f96427fe3c9f2e5815876887bc66f65c700..847ad44bdf745ab51841d2782badeab5413069d5 100644 (file)
@@ -58,7 +58,7 @@ static void HandleMediaListItemAdded(const libvlc_event_t * event, void * user_d
                                                           [VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item], @"media",
                                                           [NSNumber numberWithInt:event->u.media_list_item_added.index], @"index",
                                                           nil]]];
-    [pool release];
+    [pool drain];
 }
 
 static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data)
@@ -68,7 +68,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
     [[VLCEventManager sharedManager] callOnMainThreadObject:self
                                                  withMethod:@selector(mediaListItemRemoved:)
                                        withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]];
-    [pool release];
+    [pool drain];
 }
 
 @implementation VLCMediaList
@@ -77,19 +77,26 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
     if (self = [super init])
     {
         // Create a new libvlc media list instance
-        libvlc_exception_t p_e;
-        libvlc_exception_init( &p_e );
-        p_mlist = libvlc_media_list_new( [VLCLibrary sharedInstance], &p_e );
-        catch_exception( &p_e );
+        p_mlist = libvlc_media_list_new([VLCLibrary sharedInstance]);
 
         // Initialize internals to defaults
         cachedMedia = [[NSMutableArray alloc] init];
-        delegate = flatAspect = hierarchicalAspect = hierarchicalNodeAspect = nil;
         [self initInternalMediaList];
     }
     return self;
 }
 
+- (id)initWithArray:(NSArray *)array
+{
+    self = [self init];
+    if (!self)
+        return nil;
+
+    for (VLCMedia *media in array)
+        [self addMedia:media];
+    return self;
+}
+
 - (void)release
 {
     @synchronized(self)
@@ -114,9 +121,6 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
 
     libvlc_media_list_release( p_mlist );
     [cachedMedia release];
-    [flatAspect release];
-    [hierarchicalAspect release];
-    [hierarchicalNodeAspect release];
     [super dealloc];
 }
 
@@ -153,10 +157,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
     [media retain];
 
     // Add it to the libvlc's medialist
-    libvlc_exception_t p_e;
-    libvlc_exception_init( &p_e );
-    libvlc_media_list_insert_media( p_mlist, [media libVLCMediaDescriptor], index, &p_e );
-    catch_exception( &p_e );
+    libvlc_media_list_insert_media(p_mlist, [media libVLCMediaDescriptor], index);
 }
 
 - (void)removeMediaAtIndex:(NSInteger)index
@@ -164,10 +165,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
     [[self mediaAtIndex:index] release];
 
     // Remove it from the libvlc's medialist
-    libvlc_exception_t p_e;
-    libvlc_exception_init( &p_e );
-    libvlc_media_list_remove_index( p_mlist, index, &p_e );
-    catch_exception( &p_e );
+    libvlc_media_list_remove_index(p_mlist, index);
 }
 
 - (VLCMedia *)mediaAtIndex:(NSInteger)index
@@ -214,40 +212,6 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
     return libvlc_media_list_is_readonly( p_mlist );
 }
 
-/* Media list aspect */
-- (VLCMediaListAspect *)hierarchicalAspect
-{
-    if( hierarchicalAspect )
-        return hierarchicalAspect;
-
-    libvlc_media_list_view_t * p_mlv = libvlc_media_list_hierarchical_view( p_mlist, NULL );
-    hierarchicalAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
-    libvlc_media_list_view_release( p_mlv );
-    return hierarchicalAspect;
-}
-
-- (VLCMediaListAspect *)hierarchicalNodeAspect
-{
-    if( hierarchicalNodeAspect )
-        return hierarchicalNodeAspect;
-
-    libvlc_media_list_view_t * p_mlv = libvlc_media_list_hierarchical_node_view( p_mlist, NULL );
-    hierarchicalNodeAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
-    libvlc_media_list_view_release( p_mlv );
-    return hierarchicalNodeAspect;
-}
-
-- (VLCMediaListAspect *)flatAspect
-{
-    if( flatAspect )
-        return flatAspect;
-
-    libvlc_media_list_view_t * p_mlv = libvlc_media_list_flat_view( p_mlist, NULL );
-    flatAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
-    libvlc_media_list_view_release( p_mlv );
-    return flatAspect;
-}
-
 @end
 
 @implementation VLCMediaList (LibVLCBridging)
@@ -268,7 +232,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
         NSUInteger i, count = libvlc_media_list_count(p_mlist);
         for( i = 0; i < count; i++ )
         {
-            libvlc_media_t * p_md = libvlc_media_list_item_at_index( p_mlist, i, NULL );
+            libvlc_media_t * p_md = libvlc_media_list_item_at_index(p_mlist, i);
             [cachedMedia addObject:[VLCMedia mediaWithLibVLCMediaDescriptor:p_md]];
             libvlc_media_release(p_md);
         }