]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
macosx: Fix a deadlock in the broken -[VLCPlaylist isItem: inNode: checkItemExistence...
[vlc] / modules / gui / macosx / playlist.m
index c81aaff39b6a5474740924b8416e505b8469e0de..69d9fbbc90cf73323070621febd40c21badb5b0e 100644 (file)
 - (BOOL)isItem: (playlist_item_t *)p_item
                     inNode: (playlist_item_t *)p_node
                     checkItemExistence:(BOOL)b_check
+{
+    [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];
+}
+
+- (BOOL)isItem: (playlist_item_t *)p_item
+                    inNode: (playlist_item_t *)p_node
+                    checkItemExistence:(BOOL)b_check
+                    locked:(BOOL)b_locked
 
 {
     playlist_t * p_playlist = pl_Yield( VLCIntf );
     if ( p_temp_item )
     {
         int i;
-        PL_LOCK;
+        if(!b_locked) PL_LOCK;
 
         if( b_check )
         {
                 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
                 else if ( i == p_playlist->all_items.i_size - 1 )
                 {
+                    if(!b_locked) PL_UNLOCK;
                     vlc_object_release( p_playlist );
-                    PL_UNLOCK;
                     return NO;
                 }
             }
             p_temp_item = p_temp_item->p_parent;
             if( p_temp_item == p_node )
             {
-                PL_UNLOCK;
+                if(!b_locked) PL_UNLOCK;
                 vlc_object_release( p_playlist );
                 return YES;
             }
         }
-        PL_UNLOCK;
+        if(!b_locked) PL_UNLOCK;
     }
 
     vlc_object_release( p_playlist );
             }
             if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
                     inNode: [[o_nodes objectAtIndex:j] pointerValue]
-                    checkItemExistence: NO] )
+                    checkItemExistence: NO locked:NO] )
             {
                 [o_items removeObjectAtIndex:i];
                 /* We need to execute the next iteration with the same index
             if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
                 [self isItem: p_playlist->status.p_item inNode:
                         ((playlist_item_t *)[o_item pointerValue])
-                        checkItemExistence: NO] == YES )
+                        checkItemExistence: NO locked:YES] == YES )
                 // if current item is in selected node and is playing then stop playlist
                 playlist_Stop( p_playlist );
     
         /* Get the item */
         o_one_item = [o_array objectAtIndex: i_item];
         p_input = [self createItem: o_one_item];
-        if( !p_input )
-        {
-            continue;
-        }
+
+        if( !p_input ) continue;
 
         /* Add the item */
-        /* FIXME: playlist_NodeAddInput() can fail */
-       playlist_NodeAddInput( p_playlist, p_input, p_node,
+        /* FIXME: playlist_BothAddInput() can fail */
+       playlist_BothAddInput( p_playlist, p_input, p_node,
                                       PLAYLIST_INSERT,
                                       i_position == -1 ?
-                                      PLAYLIST_END : i_position + i_item, false );
+                                      PLAYLIST_END : i_position + i_item,
+                                      NULL, NULL, false );
 
 
         if( i_item == 0 && !b_enqueue )
 
         if ( item == nil )
         {
-            [self appendArray: o_array atPos: index enqueue: YES];
+            [self appendArray:o_array atPos:index enqueue: YES];
         }
         else
         {
             assert( p_node->i_children != -1 );
-            [self appendNodeArray: o_array inNode: p_node
-                atPos: index enqueue: YES];
+            [self appendNodeArray:o_array inNode: p_node
+                atPos:index enqueue:YES];
         }
         vlc_object_release( p_playlist );
         return YES;