Setting that argument to NULL will make playlist_CreateNode() behave like previously.
That way we can create only one input per pair of node (for local playlist, media library, and service discovery)
Previous behaviour was to create 2 inputs with the same i_id member, but we would store both input in a binary search tree (sorted by i_id), and that kind of tree MUST NOT have 2 items with the same key, else we will get some bad memory corruption when the wrong input is removed from the tree (the other being left in the tree while the memory referred by it was freed).
Note that this breaks ABI
VLC_EXPORT( int, playlist_NodeChildrenCount, (playlist_t *,playlist_item_t* ) );
/* Node management */
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, int i_flags ) );
+VLC_EXPORT( playlist_item_t *, playlist_NodeCreate, ( playlist_t *, const char *, playlist_item_t * p_parent, int i_flags, input_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_NodeRemoveItem, (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_NodeRemoveItem, (playlist_t *,playlist_item_t*,playlist_item_t *) );
p_node = playlist_NodeCreate( p_playlist, entry,
p_parent_category,
p_node = playlist_NodeCreate( p_playlist, entry,
p_parent_category,
+ PLAYLIST_NO_REBUILD, NULL );
/* If we had the parent in category, the it is now node.
* Else, we still don't have */
/* If we had the parent in category, the it is now node.
* Else, we still don't have */
if( psz_name != NULL && psz_name != "" )
p_item = playlist_NodeCreate( p_playlist, psz_name,
if( psz_name != NULL && psz_name != "" )
p_item = playlist_NodeCreate( p_playlist, psz_name,
- p_playlist->p_local_category, 0 );
+ p_playlist->p_local_category, 0, NULL );
else if(! config_GetInt( p_playlist, "interact" ) )
{
/* in case that the interaction is disabled, just give it a bogus name */
p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
else if(! config_GetInt( p_playlist, "interact" ) )
{
/* in case that the interaction is disabled, just give it a bogus name */
p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
- p_playlist->p_local_category, 0 );
+ p_playlist->p_local_category, 0, NULL );
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, 0 );
+ playlist_NodeCreate( p_playlist, psz_name, p_item, 0, NULL );
UnlockPlaylist( p_intf->p_sys, p_playlist );
Rebuild( VLC_TRUE );
UnlockPlaylist( p_intf->p_sys, p_playlist );
Rebuild( VLC_TRUE );
*/
char *str = strdup( dev->getFriendlyName( ) );
*/
char *str = strdup( dev->getFriendlyName( ) );
- p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat,0 );
+ p_item = playlist_NodeCreate( p_playlist, str, p_sd->p_cat, 0, NULL );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
msg_Dbg( p_sd, "device %s added", str );
free( str );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
msg_Dbg( p_sd, "device %s added", str );
free( str );
ContainerNode *conNode = (ContainerNode *)node;
char* p_name = strdup(title); /* See other comment on strdup */
ContainerNode *conNode = (ContainerNode *)node;
char* p_name = strdup(title); /* See other comment on strdup */
- playlist_item_t* p_node = playlist_NodeCreate( p_playlist,
- p_name, p_parent, 0 );
+ playlist_item_t* p_node = playlist_NodeCreate( p_playlist, p_name,
+ p_parent, 0, NULL );
free(p_name);
unsigned nContentNodes = conNode->getNContentNodes();
free(p_name);
unsigned nContentNodes = conNode->getNContentNodes();
playlist_item_t* parentNode = parent->getPlaylistNode();
char* title = strdup( container->getTitle() );
playlist_item_t* parentNode = parent->getPlaylistNode();
char* title = strdup( container->getTitle() );
- playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0 );
+ playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0, NULL );
free( title );
container->setPlaylistNode( node );
free( title );
container->setPlaylistNode( node );
char* name = strdup( s->getFriendlyName() );
playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ),
name,
char* name = strdup( s->getFriendlyName() );
playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ),
name,
- _cookie->serviceDiscovery->p_sys->p_node_cat, 0 );
+ _cookie->serviceDiscovery->p_sys->p_node_cat, 0, NULL );
free( name );
s->setPlaylistNode( node );
free( name );
s->setPlaylistNode( node );
var_CreateGetBool( p_playlist, "auto-preparse") ;
p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL,
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_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL,
+ 0, p_playlist->p_root_category->p_input );
if( !p_playlist->p_root_category || !p_playlist->p_root_onelevel )
return NULL;
/* Create playlist and media library */
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, 0 );
- p_playlist->p_local_onelevel = playlist_NodeCreate( p_playlist,
- _( "Playlist" ), p_playlist->p_root_onelevel, 0 );
+ playlist_NodesPairCreate( p_playlist, _( "Playlist" ),
+ &p_playlist->p_local_category,
+ &p_playlist->p_local_onelevel, VLC_FALSE );
+
p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_local_onelevel->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->p_input )
return NULL;
!p_playlist->p_local_onelevel->p_input )
return NULL;
- /* Link the nodes together. Todo: actually create them from the same input*/
- p_playlist->p_local_onelevel->p_input->i_id =
- p_playlist->p_local_category->p_input->i_id;
-
if( config_GetInt( p_playlist, "media-library") )
{
if( config_GetInt( p_playlist, "media-library") )
{
- p_playlist->p_ml_category = playlist_NodeCreate( p_playlist,
- _( "Media Library" ), p_playlist->p_root_category, 0 );
- p_playlist->p_ml_onelevel = playlist_NodeCreate( p_playlist,
- _( "Media Library" ), p_playlist->p_root_onelevel, 0 );
+ playlist_NodesPairCreate( p_playlist, _( "Media Library" ),
+ &p_playlist->p_ml_category,
+ &p_playlist->p_ml_onelevel, VLC_FALSE );
if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel)
return NULL;
p_playlist->p_ml_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_ml_onelevel->i_flags |= PLAYLIST_RO_FLAG;
if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel)
return NULL;
p_playlist->p_ml_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_ml_onelevel->i_flags |= PLAYLIST_RO_FLAG;
- p_playlist->p_ml_onelevel->p_input->i_id =
- p_playlist->p_ml_category->p_input->i_id;
-
if( !p_cat )
{
p_cat = playlist_NodeCreate( p_parent->p_playlist, psz_cat,
if( !p_cat )
{
p_cat = playlist_NodeCreate( p_parent->p_playlist, psz_cat,
p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
}
p_parent = p_cat;
p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
}
p_parent = p_cat;
* \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
* \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
+ * \param p_input the input_item to attach to or NULL if it has to be created
* \return the new node
*/
playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
const char *psz_name,
* \return the new node
*/
playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
const char *psz_name,
- playlist_item_t *p_parent, int i_flags )
+ playlist_item_t *p_parent, int i_flags,
+ input_item_t *p_input )
+ input_item_t *p_new_input;
playlist_item_t *p_item;
if( !psz_name ) psz_name = _("Undefined");
playlist_item_t *p_item;
if( !psz_name ) psz_name = _("Undefined");
- p_input = input_ItemNewWithType( VLC_OBJECT(p_playlist), NULL, psz_name,
- 0, NULL, -1, ITEM_TYPE_NODE );
- p_item = playlist_ItemNewFromInput( VLC_OBJECT(p_playlist), p_input );
+
+ if( !p_input )
+ p_new_input = input_ItemNewWithType( VLC_OBJECT(p_playlist), NULL,
+ psz_name, 0, NULL, -1, ITEM_TYPE_NODE );
+ p_item = playlist_ItemNewFromInput( VLC_OBJECT(p_playlist),
+ p_input ? p_input : p_new_input );
if( p_item == NULL ) return NULL;
p_item->i_children = 0;
if( p_item == NULL ) return NULL;
p_item->i_children = 0;
/**
* Create a pair of nodes in the category and onelevel trees.
/**
* Create a pair of nodes in the category and onelevel trees.
- * They share the same input ID.
- * \todo really share the input item
+ * They share the same input item.
* \param p_playlist the playlist
* \param psz_name the name of the nodes
* \param pp_node_cat pointer to return the node in category tree
* \param p_playlist the playlist
* \param psz_name the name of the nodes
* \param pp_node_cat pointer to return the node in category tree
vlc_bool_t b_for_sd )
{
*pp_node_cat = playlist_NodeCreate( p_playlist, psz_name,
vlc_bool_t b_for_sd )
{
*pp_node_cat = playlist_NodeCreate( p_playlist, psz_name,
- p_playlist->p_root_category, 0 );
+ p_playlist->p_root_category, 0, NULL );
*pp_node_one = playlist_NodeCreate( p_playlist, psz_name,
*pp_node_one = playlist_NodeCreate( p_playlist, psz_name,
- p_playlist->p_root_onelevel, 0 );
- (*pp_node_one)->p_input->i_id = (*pp_node_cat)->p_input->i_id;
+ p_playlist->p_root_onelevel, 0,
+ (*pp_node_cat)->p_input );
if( b_for_sd )
{
(*pp_node_cat)->i_flags |= PLAYLIST_RO_FLAG;
if( b_for_sd )
{
(*pp_node_cat)->i_flags |= PLAYLIST_RO_FLAG;