/** * Remove all the children of a node * * This function must be entered with the playlist lock * * \param p_playlist the playlist * \param p_root the node * \param b_delete_items do we have to delete the children items ? * \return VLC_SUCCESS or an error */ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root, bool b_delete_items ) { PL_ASSERT_LOCKED; int i; if( p_root->i_children == -1 ) { return VLC_EGENERIC; } /* Delete the children */ for( i = p_root->i_children-1 ; i >= 0 ;i-- ) { if( p_root->pp_children[i]->i_children > -1 ) { playlist_NodeDelete( p_playlist, p_root->pp_children[i], b_delete_items , false ); } else if( b_delete_items ) { /* Delete the item here */ playlist_DeleteFromItemId( p_playlist, p_root->pp_children[i]->i_id ); } } return VLC_SUCCESS; }
/** * Remove all the children of a node and removes the node * * \param p_playlist the playlist * \param p_root the node * \param b_delete_items do we have to delete the children items ? * \return VLC_SUCCESS or an error */ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root, bool b_delete_items, bool b_force ) { PL_ASSERT_LOCKED; int i; if( p_root->i_children == -1 ) { return VLC_EGENERIC; } /* Delete the children */ for( i = p_root->i_children - 1 ; i >= 0; i-- ) { if( p_root->pp_children[i]->i_children > -1 ) { playlist_NodeDelete( p_playlist, p_root->pp_children[i], b_delete_items , b_force ); } else if( b_delete_items ) { playlist_DeleteFromItemId( p_playlist, p_root->pp_children[i]->i_id ); } } /* Delete the node */ if( p_root->i_flags & PLAYLIST_RO_FLAG && !b_force ) { } else { int i; var_SetInteger( p_playlist, "playlist-item-deleted", p_root->i_id ); ARRAY_BSEARCH( p_playlist->all_items, ->i_id, int, p_root->i_id, i ); if( i != -1 ) ARRAY_REMOVE( p_playlist->all_items, i ); /* Remove the item from its parent */ if( p_root->p_parent ) playlist_NodeRemoveItem( p_playlist, p_root, p_root->p_parent ); playlist_ItemRelease( p_root ); } return VLC_SUCCESS; }