* Do not take and release the structure lock for each element of the list while
authorClément Stenac <zorglub@videolan.org>
Sun, 10 Dec 2006 14:00:54 +0000 (14:00 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 10 Dec 2006 14:00:54 +0000 (14:00 +0000)
  releasing it. mutex locks /= 20 on a standard preparse run
* Only create absolutely necessary variables while preparsing
--> Preparse speed *= 4 (with item in disk cache of course)

* Do not rebuild playlist too much while adding a directory. Add a new flag
  to NodeCreate and Add to control this behaviour

19 files changed:
include/vlc/vlc.h
include/vlc_playlist.h
modules/access/directory.c
modules/gui/macosx/playlist.m
modules/gui/wxwidgets/dialogs/playlist.cpp
modules/services_discovery/bonjour.c
modules/services_discovery/podcast.c
modules/services_discovery/sap.c
modules/services_discovery/upnp_cc.cpp
modules/services_discovery/upnp_intel.cpp
src/input/es_out.c
src/input/input.c
src/input/var.c
src/libvlc-common.c
src/misc/objects.c
src/playlist/engine.c
src/playlist/item.c
src/playlist/playlist_internal.h
src/playlist/tree.c

index 0f11446..c2e2cde 100644 (file)
@@ -142,6 +142,7 @@ struct vlc_list_t
 #define PLAYLIST_GO              0x0004
 #define PLAYLIST_PREPARSE        0x0008
 #define PLAYLIST_SPREPARSE       0x0010
+#define PLAYLIST_NO_REBUILD      0x0020
 
 #define PLAYLIST_END           -666
 
index 78be381..860759b 100644 (file)
@@ -394,7 +394,7 @@ VLC_EXPORT(void, playlist_NodeDump, ( playlist_t *p_playlist, playlist_item_t *p
 VLC_EXPORT( int, playlist_NodeChildrenCount, (playlist_t *,playlist_item_t* ) );
 
 /* Node management */
-VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent ) );
+VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags ) );
 VLC_EXPORT( int, playlist_NodeAppend, (playlist_t *,playlist_item_t*,playlist_item_t *) );
 VLC_EXPORT( int, playlist_NodeInsert, (playlist_t *,playlist_item_t*,playlist_item_t *, int) );
 VLC_EXPORT( int, playlist_NodeRemoveItem, (playlist_t *,playlist_item_t*,playlist_item_t *) );
index e3ee777..b0ea03b 100644 (file)
@@ -237,6 +237,8 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
     var_SetInteger( p_playlist, "activity", i_activity -
                     DIRECTORY_ACTIVITY );
 
+    playlist_Signal( p_playlist );
+
     if( psz_name ) free( psz_name );
     vlc_object_release( p_playlist );
 
@@ -433,8 +435,9 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
                 {
                     msg_Dbg(p_playlist, "creading subdirectory %s", psz_uri );
 
-                    p_node = playlist_NodeCreate (p_playlist, entry,
-                                                  p_parent_category);
+                    p_node = playlist_NodeCreate( p_playlist, entry,
+                                                  p_parent_category,
+                                                  PLAYLIST_NO_REBUILD );
 
                     /* If we had the parent in category, the it is now node.
                      * Else, we still don't have  */
@@ -482,7 +485,8 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
                         input_ItemCopyOptions( p_current_input, p_input );
                     playlist_BothAddInput( p_playlist, p_input,
                                            p_parent_category,
-                                           PLAYLIST_APPEND|PLAYLIST_PREPARSE,
+                                           PLAYLIST_APPEND|PLAYLIST_PREPARSE|
+                                           PLAYLIST_NO_REBUILD,
                                            PLAYLIST_END, NULL, NULL );
                 }
             }
index ccc92c8..9795763 100644 (file)
@@ -1343,10 +1343,10 @@ NSLog( @"expandable" );
         _("Please enter a name for the new node."), &psz_name );
     if( psz_name != NULL && psz_name != "" )
         p_item = playlist_NodeCreate( p_playlist, psz_name, 
-                                            p_playlist->p_local_category );
+                                            p_playlist->p_local_category, 0 );
     else
         p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"), 
-                                            p_playlist->p_local_category );
+                                            p_playlist->p_local_category, 0 );
 
     if(! p_item )
         msg_Warn( VLCIntf, "node creation failed" );
index 017b1e2..249b51b 100644 (file)
@@ -1636,7 +1636,7 @@ void Playlist::OnPopupAddNode( wxCommandEvent& event )
 
     p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
 
-    playlist_NodeCreate( p_playlist, psz_name, p_item );
+    playlist_NodeCreate( p_playlist, psz_name, p_item, 0 );
 
     UnlockPlaylist( p_intf->p_sys, p_playlist );
     Rebuild( VLC_TRUE );
index 7e016f7..f3108d8 100644 (file)
@@ -307,9 +307,9 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_sys->p_node_cat = playlist_NodeCreate( p_sys->p_playlist, _("Bonjour"),
-                                             p_sys->p_playlist->p_root_category );
+                                       p_sys->p_playlist->p_root_category, 0 );
     p_sys->p_node_one = playlist_NodeCreate( p_sys->p_playlist, _("Bonjour"),
-                                             p_sys->p_playlist->p_root_onelevel );
+                                       p_sys->p_playlist->p_root_onelevel, 0 );
     p_sys->p_node_one->p_input->i_id = p_sys->p_node_cat->p_input->i_id;
 
     p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG;
index 3428f52..42f6574 100644 (file)
@@ -149,9 +149,9 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_sys->p_node_cat = playlist_NodeCreate( p_playlist, _("Podcast"),
-                                         p_playlist->p_root_category );
+                                         p_playlist->p_root_category, 0 );
     p_sys->p_node_one = playlist_NodeCreate( p_playlist, _("Podcast"),
-                                         p_playlist->p_root_onelevel );
+                                         p_playlist->p_root_onelevel, 0 );
     p_sys->p_node_one->p_input->i_id = p_sys->p_node_cat->p_input->i_id;
 
     p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG;
index a295b0d..b485049 100644 (file)
@@ -802,7 +802,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
         if( p_child == NULL )
         {
             p_child = playlist_NodeCreate( pl_Get( p_sd ), psz_value,
-                                           p_sys->p_node_cat );
+                                           p_sys->p_node_cat, 0 );
             p_child->i_flags &= ~PLAYLIST_SKIP_FLAG;
         }
     }
index 057cf7a..e05900b 100644 (file)
@@ -206,7 +206,7 @@ playlist_item_t *UPnPHandler::AddDevice( Device *dev )
      */
     char *str = strdup( dev->getFriendlyName( ) );
 
-    p_item = playlist_NodeCreate( p_sys->p_playlist, str, p_sys->p_node_cat );
+    p_item = playlist_NodeCreate( p_sys->p_playlist, str, p_sys->p_node_cat,0 );
     p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
     msg_Dbg( p_sd, "device %s added", str );
     free( str );
@@ -247,7 +247,7 @@ void UPnPHandler::AddContent( playlist_item_t *p_parent, ContentNode *node )
 
         char* p_name = strdup(title); /* See other comment on strdup */
         playlist_item_t* p_node = playlist_NodeCreate( p_sys->p_playlist,
-                                                       p_name, p_parent );
+                                                       p_name, p_parent, 0 );
         free(p_name);
 
         unsigned nContentNodes = conNode->getNContentNodes();
index 2debe08..40a0feb 100644 (file)
@@ -854,7 +854,7 @@ void MediaServer::_buildPlaylist( Container* parent )
         playlist_item_t* parentNode = parent->getPlaylistNode();
 
         char* title = strdup( container->getTitle() );
-        playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode );
+        playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0 );
         free( title );
 
         container->setPlaylistNode( node );
@@ -916,7 +916,7 @@ bool MediaServerList::addServer( MediaServer* s )
     char* name = strdup( s->getFriendlyName() );
     playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ),
                                                  name,
-                                          _cookie->serviceDiscovery->p_sys->p_node_cat );
+                                          _cookie->serviceDiscovery->p_sys->p_node_cat, 0 );
     free( name );
     s->setPlaylistNode( node );
 
index 49e88d7..22eb629 100644 (file)
@@ -177,25 +177,33 @@ es_out_t *input_EsOutNew( input_thread_t *p_input )
     var_Get( p_input, "sub-track", &val );
     p_sys->i_sub_last = val.i_int;
 
-    var_Get( p_input, "audio-language", &val );
-    p_sys->ppsz_audio_language = LanguageSplit(val.psz_string);
-    if( p_sys->ppsz_audio_language )
+    if( !p_input->b_preparsing )
     {
-        for( i = 0; p_sys->ppsz_audio_language[i]; i++ )
-            msg_Dbg( p_input, "selected audio language[%d] %s",
-                     i, p_sys->ppsz_audio_language[i] );
-    }
-    if( val.psz_string ) free( val.psz_string );
+        var_Get( p_input, "audio-language", &val );
+        p_sys->ppsz_audio_language = LanguageSplit(val.psz_string);
+        if( p_sys->ppsz_audio_language )
+        {
+            for( i = 0; p_sys->ppsz_audio_language[i]; i++ )
+                msg_Dbg( p_input, "selected audio language[%d] %s",
+                         i, p_sys->ppsz_audio_language[i] );
+        }
+        if( val.psz_string ) free( val.psz_string );
 
-    var_Get( p_input, "sub-language", &val );
-    p_sys->ppsz_sub_language = LanguageSplit(val.psz_string);
-    if( p_sys->ppsz_sub_language )
+        var_Get( p_input, "sub-language", &val );
+        p_sys->ppsz_sub_language = LanguageSplit(val.psz_string);
+        if( p_sys->ppsz_sub_language )
+        {
+            for( i = 0; p_sys->ppsz_sub_language[i]; i++ )
+                msg_Dbg( p_input, "selected subtitle language[%d] %s",
+                         i, p_sys->ppsz_sub_language[i] );
+        }
+        if( val.psz_string ) free( val.psz_string );
+    }
+    else
     {
-        for( i = 0; p_sys->ppsz_sub_language[i]; i++ )
-            msg_Dbg( p_input, "selected subtitle language[%d] %s",
-                     i, p_sys->ppsz_sub_language[i] );
+        p_sys->ppsz_sub_language = NULL;
+        p_sys->ppsz_audio_language = NULL;
     }
-    if( val.psz_string ) free( val.psz_string );
 
     var_Get( p_input, "audio-track-id", &val );
     p_sys->i_audio_id = val.i_int;
index 8e327b5..ec1a3f0 100644 (file)
@@ -197,7 +197,9 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     input_ConfigVarInit( p_input );
 
     /* Create Objects variables for public Get and Set */
-    input_ControlVarInit( p_input );
+    if( !p_input->b_preparsing )
+        input_ControlVarInit( p_input );
+
     p_input->p->input.i_cr_average = var_GetInteger( p_input, "cr-average" );
 
     if( !p_input->b_preparsing )
@@ -1147,7 +1149,8 @@ static void End( input_thread_t * p_input )
     input_ChangeState( p_input, END_S );
 
     /* Clean control variables */
-    input_ControlVarClean( p_input );
+    if( !p_input->b_preparsing )
+        input_ControlVarClean( p_input );
 
     /* Clean up master */
     InputSourceClean( p_input, &p_input->p->input );
index c255e01..f10493b 100644 (file)
@@ -386,56 +386,68 @@ void input_ConfigVarInit ( input_thread_t *p_input )
     vlc_value_t val;
 
     /* Create Object Variables for private use only */
-    var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 
-    var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "audio-language", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-language", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "audio-track-id", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-track-id", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
-                VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
-                VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
-                VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sout-all",   VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "sout-keep",  VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "input-repeat", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-    var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "minimize-threads", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
+    if( !p_input->b_preparsing )
+    {
+        var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "audio-language",
+                    VLC_VAR_STRING|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-language",
+                    VLC_VAR_STRING|VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "audio-track-id",
+                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-track-id",
+                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
+                    VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
+                    VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
+                    VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sout-all",   VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sout-keep",  VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "input-repeat",
+                    VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "input-slave",
+                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "minimize-threads",
+                    VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
+
+        var_Create( p_input, "audio-desync",
+                    VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "cr-average",
+                    VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "clock-synchro",
+                    VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
+    }
 
     var_Create( p_input, "demuxed-id3", VLC_VAR_BOOL ); /* FIXME beurk */
     val.b_bool = VLC_FALSE;
     var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL );
 
-    var_Create( p_input, "audio-desync", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
-    var_Create( p_input, "cr-average", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    var_Create( p_input, "clock-synchro", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
-
     var_Create( p_input, "seekable", VLC_VAR_BOOL );
     val.b_bool = VLC_TRUE; /* Fixed later*/
     var_Change( p_input, "seekable", VLC_VAR_SETVALUE, &val, NULL );
 
-    var_Create( p_input, "input-slave", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-
     /* */
     var_Create( p_input, "access-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
index b69d7fc..804f3c0 100644 (file)
@@ -579,7 +579,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
         /* Initialise D-Bus interface, check for other instances */
         DBusConnection  *p_conn;
         DBusError       dbus_error;
-        int             i_dbus_service;
 
         dbus_threads_init_default();
         dbus_error_init( &dbus_error );
index cc78ee9..6659919 100644 (file)
@@ -852,14 +852,12 @@ void vlc_list_release( vlc_list_t *p_list )
 {
     int i_index;
 
+    vlc_mutex_lock( &structure_lock );
     for( i_index = 0; i_index < p_list->i_count; i_index++ )
     {
-        vlc_mutex_lock( &structure_lock );
-
         p_list->p_values[i_index].p_object->i_refcount--;
-
-        vlc_mutex_unlock( &structure_lock );
     }
+    vlc_mutex_unlock( &structure_lock );
 
     free( p_list->p_values );
     free( p_list );
index cad9f95..f83409d 100644 (file)
@@ -94,17 +94,19 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     p_playlist->b_auto_preparse =
                         var_CreateGetBool( p_playlist, "auto-preparse") ;
 
-    p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL);
-    p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL);
+    p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL,
+                                                       0 );
+    p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL,
+                                                       0 );
 
     if( !p_playlist->p_root_category || !p_playlist->p_root_onelevel )
         return NULL;
 
     /* Create playlist and media library */
     p_playlist->p_local_category = playlist_NodeCreate( p_playlist,
-                                 _( "Playlist" ),p_playlist->p_root_category );
+                              _( "Playlist" ),p_playlist->p_root_category, 0 );
     p_playlist->p_local_onelevel =  playlist_NodeCreate( p_playlist,
-                                _( "Playlist" ), p_playlist->p_root_onelevel );
+                              _( "Playlist" ), p_playlist->p_root_onelevel, 0 );
     p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG;
     p_playlist->p_local_onelevel->i_flags |= PLAYLIST_RO_FLAG;
 
@@ -120,9 +122,9 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     if( config_GetInt( p_playlist, "media-library") )
     {
         p_playlist->p_ml_category =   playlist_NodeCreate( p_playlist,
-                           _( "Media Library" ), p_playlist->p_root_category );
+                         _( "Media Library" ), p_playlist->p_root_category, 0 );
         p_playlist->p_ml_onelevel =  playlist_NodeCreate( p_playlist,
-                           _( "Media Library" ), p_playlist->p_root_onelevel );
+                         _( "Media Library" ), p_playlist->p_root_onelevel, 0 );
 
         if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel)
             return NULL;
index c299e34..e3bfc95 100644 (file)
 #include <vlc_playlist.h>
 #include "playlist_internal.h"
 
-void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
-              playlist_item_t *p_node, int i_pos );
-void GoAndPreparse( playlist_t *p_playlist, int i_mode,
-                    playlist_item_t *, playlist_item_t * );
-void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
-int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
-                          vlc_bool_t b_stop );
+static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
+                     playlist_item_t *p_node, int i_mode, int i_pos );
+static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
+                           playlist_item_t *, playlist_item_t * );
+static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
+static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
+                        vlc_bool_t b_stop );
 
 /*****************************************************************************
  * Playlist item creation
@@ -206,14 +206,14 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
     if( p_item_one == NULL ) return VLC_EGENERIC;
     AddItem( p_playlist, p_item_one,
              b_playlist ? p_playlist->p_local_onelevel :
-                          p_playlist->p_ml_onelevel , i_pos );
+                          p_playlist->p_ml_onelevel , i_mode, i_pos );
 
     /* Add to CATEGORY */
     p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
     if( p_item_cat == NULL ) return VLC_EGENERIC;
     AddItem( p_playlist, p_item_cat,
              b_playlist ? p_playlist->p_local_category :
-                          p_playlist->p_ml_category , i_pos );
+                          p_playlist->p_ml_category , i_mode, i_pos );
 
     GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
 
@@ -237,7 +237,7 @@ int playlist_BothAddInput( playlist_t *p_playlist,
     /* Add to category */
     p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
     if( p_item_cat == NULL ) return VLC_EGENERIC;
-    AddItem( p_playlist, p_item_cat, p_direct_parent, i_pos );
+    AddItem( p_playlist, p_item_cat, p_direct_parent, i_mode, i_pos );
 
     /* Add to onelevel */
     /** \todo make a faster case for ml import */
@@ -255,7 +255,8 @@ int playlist_BothAddInput( playlist_t *p_playlist,
                              p_up->p_input->i_id )
         {
             AddItem( p_playlist, p_item_one,
-                     p_playlist->p_root_onelevel->pp_children[i_top], i_pos );
+                     p_playlist->p_root_onelevel->pp_children[i_top],
+                     i_mode, i_pos );
             break;
         }
     }
@@ -282,7 +283,7 @@ playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
 
     p_item = playlist_ItemNewFromInput( p_playlist, p_input );
     if( p_item == NULL ) return NULL;
-    AddItem( p_playlist, p_item, p_parent, i_pos );
+    AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
 
     vlc_mutex_unlock( &p_playlist->object_lock );
 
@@ -475,7 +476,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
 
 /** Send a notification that an item has been added to a node */
 void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
-                             int i_node_id )
+                             int i_node_id, vlc_bool_t b_signal )
 {
     vlc_value_t val;
     playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t));
@@ -483,7 +484,8 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
     p_add->i_node = i_node_id;
     val.p_address = p_add;
     p_playlist->b_reset_currently_playing = VLC_TRUE;
-    vlc_cond_signal( &p_playlist->object_wait );
+    if( b_signal )
+        vlc_cond_signal( &p_playlist->object_wait );
     var_Set( p_playlist, "item-append", val );
     free( p_add );
 }
@@ -509,8 +511,9 @@ int playlist_ItemSetName( playlist_item_t *p_item, const char *psz_name )
  ***************************************************************************/
 
 /* Enqueue an item for preparsing, and play it, if needed */
-void GoAndPreparse( playlist_t *p_playlist, int i_mode,
-                    playlist_item_t *p_item_cat, playlist_item_t *p_item_one )
+static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
+                           playlist_item_t *p_item_cat,
+                           playlist_item_t *p_item_one )
 {
     if( (i_mode & PLAYLIST_GO ) )
     {
@@ -556,8 +559,8 @@ void GoAndPreparse( playlist_t *p_playlist, int i_mode,
 }
 
 /* Add the playlist item to the requested node and fire a notification */
-void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
-              playlist_item_t *p_node, int i_pos )
+static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
+                     playlist_item_t *p_node, int i_mode, int i_pos )
 {
     ARRAY_APPEND(p_playlist->items, p_item);
     ARRAY_APPEND(p_playlist->all_items, p_item);
@@ -569,11 +572,12 @@ void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
         playlist_NodeInsert( p_playlist, p_item, p_node, i_pos );
 
     if( !p_playlist->b_doing_ml )
-        playlist_SendAddNotify( p_playlist, p_item->i_id, p_node->i_id );
+        playlist_SendAddNotify( p_playlist, p_item->i_id, p_node->i_id,
+                                 !( i_mode & PLAYLIST_NO_REBUILD ) );
 }
 
 /* Actually convert an item to a node */
-void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item )
+static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item )
 {
     int i;
     if( p_item->i_children == -1 )
@@ -586,8 +590,8 @@ void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item )
 }
 
 /* Do the actual removal */
-int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
-                vlc_bool_t b_stop )
+static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
+                        vlc_bool_t b_stop )
 {
     int i;
     int i_id = p_item->i_id;
index e3e54db..e82b677 100644 (file)
@@ -91,7 +91,8 @@ int playlist_MLDump( playlist_t *p_playlist );
  * Item management
  **********************************************************************/
 
-void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id, int i_node_id );
+void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
+                             int i_node_id, vlc_bool_t b_signal );
 
 /* Tree walking */
 int playlist_GetAllEnabledChildren( playlist_t *p_playlist,
index a3512b8..c792421 100644 (file)
@@ -46,10 +46,12 @@ playlist_item_t *GetPrevItem( playlist_t *p_playlist,
  * \param p_playlist the playlist
  * \paam psz_name the name of the node
  * \param p_parent the parent node to attach to or NULL if no attach
+ * \param p_flags miscellaneous flags
  * \return the new node
  */
-playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, const char *psz_name,
-                                       playlist_item_t *p_parent )
+playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
+                                       const char *psz_name,
+                                       playlist_item_t *p_parent, int i_flags )
 {
     input_item_t *p_input;
     playlist_item_t *p_item;
@@ -68,7 +70,8 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, const char *psz_n
     if( p_parent != NULL )
         playlist_NodeAppend( p_playlist, p_item, p_parent );
     playlist_SendAddNotify( p_playlist, p_item->i_id,
-                            p_parent ? p_parent->i_id : -1 );
+                            p_parent ? p_parent->i_id : -1,
+                            !( i_flags & PLAYLIST_NO_REBUILD ));
     return p_item;
 }
 
@@ -289,9 +292,9 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name,
                                vlc_bool_t b_for_sd )
 {
     *pp_node_cat = playlist_NodeCreate( p_playlist, psz_name,
-                                        p_playlist->p_root_category );
+                                        p_playlist->p_root_category, 0 );
     *pp_node_one = playlist_NodeCreate( p_playlist, psz_name,
-                                        p_playlist->p_root_onelevel );
+                                        p_playlist->p_root_onelevel, 0 );
     (*pp_node_one)->p_input->i_id = (*pp_node_cat)->p_input->i_id;
     if( b_for_sd )
     {