]> git.sesse.net Git - vlc/blobdiff - src/playlist/item.c
Removes trailing spaces. Removes tabs.
[vlc] / src / playlist / item.c
index f78385e9fe0800077e922b5b109899c8e284bce0..28634fe85c32252daee5f4a6385b3cf314882d3e 100644 (file)
@@ -54,8 +54,8 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
     b_play = var_CreateGetBool( p_playlist, "playlist-autostart" );
 
     /* This part is really hakish, but this playlist system isn't simple */
-    /* First check if we haven't already added the item as we are 
-     * listening using the onelevel and the category representent 
+    /* First check if we haven't already added the item as we are
+     * listening using the onelevel and the category representent
      * (Because of the playlist design) */
     p_child_in_category = playlist_ItemFindFromInputAndRoot(
                             p_playlist, p_child->i_id,
@@ -64,8 +64,6 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
 
     if( !p_child_in_category )
     {
-        b_play = b_play && p_item_in_category == p_playlist->status.p_item;
-
         /* Then, transform to a node if needed */
         p_item_in_category = playlist_ItemFindFromInputAndRoot(
                                 p_playlist, p_parent->i_id,
@@ -75,17 +73,20 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
         {
             /* Item may have been removed */
             PL_UNLOCK;
-            return
+            return;
         }
 
+        b_play = b_play && p_item_in_category == p_playlist->status.p_item;
+
         /* If this item is already a node don't transform it */
         if( p_item_in_category->i_children == -1 )
         {
             p_item_in_category = playlist_ItemToNode( p_playlist,
                     p_item_in_category, VLC_TRUE );
+            p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST;
         }
-        
-        playlist_BothAddInput( p_playlist, p_child, p_item_in_category, 
+        playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
                 PLAYLIST_APPEND | PLAYLIST_SPREPARSE , PLAYLIST_END,
                 NULL, NULL,  VLC_TRUE );
 
@@ -95,7 +96,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
                           VLC_TRUE, p_item_in_category, NULL );
         }
     }
-    
     PL_UNLOCK;
 
 }
@@ -117,7 +118,7 @@ static void uninstall_input_item_observer( playlist_item_t * p_item,
     vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                       input_item_subitem_added,
                       p_item );
-                      
 }
 
 /*****************************************************************************
@@ -169,7 +170,7 @@ playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
 /** Delete a playlist item and detach its input item */
 int playlist_ItemDelete( playlist_item_t *p_item )
 {
-    uninstall_input_item_observer( p_item->p_playlist, p_item->p_input );
+    uninstall_input_item_observer( p_item, p_item->p_input );
 
     vlc_gc_decref( p_item->p_input );
     free( p_item );
@@ -616,7 +617,7 @@ int playlist_ItemSetName( playlist_item_t *p_item, const char *psz_name )
 {
     if( psz_name && p_item )
     {
-        input_ItemSetName( p_item->p_input, psz_name );
+        input_item_SetName( p_item->p_input, psz_name );
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
@@ -657,17 +658,19 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         vlc_cond_signal( &p_playlist->object_wait );
     }
     /* Preparse if PREPARSE or SPREPARSE & not enough meta */
+    char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
+    char *psz_album = input_item_GetAlbum( p_item_cat->p_input );
     if( p_playlist->b_auto_preparse &&
           (i_mode & PLAYLIST_PREPARSE ||
           ( i_mode & PLAYLIST_SPREPARSE &&
-            ( EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) ||
-            ( EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) ) )
+            ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) )
           ) ) )
         playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input );
     /* If we already have it, signal it */
-    else if( !EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) &&
-             !EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) )
+    else if( !EMPTY_STR( psz_artist ) && !EMPTY_STR( psz_album ) )
         input_item_SetPreparsed( p_item_cat->p_input, VLC_TRUE );
+    free( psz_artist );
+    free( psz_album );
 }
 
 /* Add the playlist item to the requested node and fire a notification */