Commit 50c44e46 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: remove item parameter of playlist_NodeCreate()

Nodes are not supposed to have real input items. The parameter was
always NULL, except when copying another node, in which case it did not
matter whether it was or was not NULL.
parent df87ece4
......@@ -351,7 +351,7 @@ VLC_API int playlist_LiveSearchUpdate(playlist_t *, playlist_item_t *, const cha
* Tree management
********************************************************/
/* Node management */
VLC_API playlist_item_t * playlist_NodeCreate( playlist_t *, const char *, playlist_item_t * p_parent, int i_pos, int i_flags, input_item_t * );
VLC_API playlist_item_t * playlist_NodeCreate( playlist_t *, const char *, playlist_item_t * p_parent, int i_pos, int i_flags );
VLC_API playlist_item_t * playlist_ChildSearchName(playlist_item_t*, const char* ) VLC_USED;
VLC_API void playlist_NodeDelete( playlist_t *, playlist_item_t *, bool );
......
......@@ -896,7 +896,7 @@ void PLModel::createNode( QModelIndex index, QString name )
if ( !index.isValid() ) index = rootIndex();
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
if( p_item )
playlist_NodeCreate( p_playlist, qtu( name ), p_item, PLAYLIST_END, 0, NULL );
playlist_NodeCreate( p_playlist, qtu( name ), p_item, PLAYLIST_END, 0 );
}
void PLModel::renameNode( QModelIndex index, QString name )
......
......@@ -159,7 +159,7 @@ void RecentsMRL::save()
playlist_item_t *RecentsMRL::toPlaylist(int length)
{
playlist_Lock(THEPL);
playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL);
playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG);
playlist_Unlock(THEPL);
if ( p_node_recent == NULL ) return NULL;
......
......@@ -234,13 +234,12 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
playlist_item_t *root, *playing, *ml;
PL_LOCK;
root = playlist_NodeCreate( p_playlist, NULL, NULL,
PLAYLIST_END, 0, NULL );
root = playlist_NodeCreate( p_playlist, NULL, NULL, PLAYLIST_END, 0 );
playing = playlist_NodeCreate( p_playlist, _( "Playlist" ), root,
PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG, NULL );
PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG );
if( var_InheritBool( p_parent, "media-library") )
ml = playlist_NodeCreate( p_playlist, _( "Media Library" ), root,
PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG, NULL );
PLAYLIST_END, PLAYLIST_RO_FLAG | PLAYLIST_NO_INHERIT_FLAG );
else
ml = NULL;
PL_UNLOCK;
......
......@@ -873,21 +873,31 @@ static int RecursiveInsertCopy (
input_item_t *p_input = p_item->p_input;
if( !(p_item->i_children != -1 && b_flat) )
if( p_item->i_children == -1 || !b_flat )
{
input_item_t *p_new_input = input_item_Copy( p_input );
if( !p_new_input ) return i_pos;
playlist_item_t *p_new_item = NULL;
if( p_item->i_children == -1 )
p_new_item = playlist_NodeAddInput( p_playlist, p_new_input,
p_parent, PLAYLIST_INSERT, i_pos,
pl_Locked );
{
input_item_t *p_new_input = input_item_Copy( p_input );
if( likely(p_new_input != NULL) )
{
p_new_item = playlist_NodeAddInput( p_playlist, p_new_input,
p_parent, PLAYLIST_INSERT,
i_pos, pl_Locked );
vlc_gc_decref( p_new_input );
}
}
else
p_new_item = playlist_NodeCreate( p_playlist, NULL,
p_parent, i_pos, 0, p_new_input );
vlc_gc_decref( p_new_input );
if( !p_new_item ) return i_pos;
{
vlc_mutex_lock( &p_input->lock );
p_new_item = playlist_NodeCreate( p_playlist, p_input->psz_name,
p_parent, i_pos, 0 );
vlc_mutex_unlock( &p_input->lock );
}
if( unlikely(p_new_item == NULL) )
return i_pos;
i_pos++;
......
......@@ -165,8 +165,7 @@ static void playlist_sd_item_added(services_discovery_t *sd,
if (sds->node == NULL)
sds->node = playlist_NodeCreate(playlist, longname, playlist->p_root,
PLAYLIST_END,
PLAYLIST_RO_FLAG|PLAYLIST_SKIP_FLAG,
NULL);
PLAYLIST_RO_FLAG|PLAYLIST_SKIP_FLAG);
/* If p_parent is in root category (this is clearly a hack) and we have a cat */
if (psz_cat == NULL)
......@@ -177,8 +176,7 @@ static void playlist_sd_item_added(services_discovery_t *sd,
if (parent == NULL)
parent = playlist_NodeCreate(playlist, psz_cat, sds->node,
PLAYLIST_END,
PLAYLIST_RO_FLAG | PLAYLIST_SKIP_FLAG,
NULL);
PLAYLIST_RO_FLAG|PLAYLIST_SKIP_FLAG);
}
playlist_NodeAddInput(playlist, p_input, parent,
......@@ -241,8 +239,7 @@ int playlist_ServicesDiscoveryAdd(playlist_t *playlist, const char *chain)
if (sds->node == NULL && sds->sd->description != NULL)
sds->node = playlist_NodeCreate(playlist, sds->sd->description,
playlist->p_root, PLAYLIST_END,
PLAYLIST_RO_FLAG|PLAYLIST_SKIP_FLAG,
NULL);
PLAYLIST_RO_FLAG|PLAYLIST_SKIP_FLAG);
TAB_APPEND(pl_priv(playlist)->i_sds, pl_priv(playlist)->pp_sds, sds);
playlist_Unlock(playlist);
......
......@@ -58,21 +58,18 @@ playlist_item_t *GetPrevItem( playlist_t *p_playlist,
playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
const char *psz_name,
playlist_item_t *p_parent, int i_pos,
int i_flags, input_item_t *p_input )
int i_flags )
{
input_item_t *p_new_input = NULL;
input_item_t *p_new_input;
playlist_item_t *p_item;
PL_ASSERT_LOCKED;
if( !psz_name ) psz_name = _("Undefined");
if( !p_input )
p_new_input = input_item_NewExt( NULL, psz_name, -1, ITEM_TYPE_NODE,
ITEM_NET_UNKNOWN );
p_item = playlist_ItemNewFromInput( p_playlist,
p_input ? p_input : p_new_input );
if( p_new_input )
vlc_gc_decref( p_new_input );
p_new_input = input_item_NewExt( NULL, psz_name, -1, ITEM_TYPE_NODE,
ITEM_NET_UNKNOWN );
p_item = playlist_ItemNewFromInput( p_playlist, p_new_input );
vlc_gc_decref( p_new_input );
if( p_item == NULL ) return NULL;
p_item->i_children = 0;
......
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