Commit 496a5420 authored by Clément Stenac's avatar Clément Stenac

* Do not take and release the structure lock for each element of the list while

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