1 /*****************************************************************************
2 * item.c : Playlist item creation/deletion/add/removal functions
3 *****************************************************************************
4 * Copyright (C) 1999-2007 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Clément Stenac <zorglub@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
26 #include <vlc_playlist.h>
27 #include "playlist_internal.h"
29 static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
30 playlist_item_t *p_node, int i_mode, int i_pos );
31 static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
32 playlist_item_t *, playlist_item_t * );
33 static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
34 static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
37 /*****************************************************************************
38 * An input item has gained a subitem (Event Callback)
39 *****************************************************************************/
40 static void input_item_subitem_added( const vlc_event_t * p_event,
43 playlist_item_t *p_parent_playlist_item = user_data;
44 playlist_t * p_playlist = p_parent_playlist_item->p_playlist;
45 input_item_t * p_parent, * p_child;
46 playlist_item_t * p_child_in_category;
47 playlist_item_t * p_item_in_category;
48 vlc_bool_t b_play, b_node;
50 p_parent = p_event->p_obj;
51 p_child = p_event->u.input_item_subitem_added.p_new_child;
52 b_node = p_event->u.input_item_subitem_added.b_node;
55 b_play = var_CreateGetBool( p_playlist, "playlist-autostart" );
57 /* This part is really hakish, but this playlist system isn't simple */
58 /* First check if we haven't already added the item as we are
59 * listening using the onelevel and the category representent
60 * (Because of the playlist design) */
61 p_child_in_category = playlist_ItemFindFromInputAndRoot(
62 p_playlist, p_child->i_id,
63 p_playlist->p_root_category,
64 VLC_FALSE /* Only non-node */ );
66 if( !p_child_in_category )
68 p_item_in_category = playlist_ItemFindFromInputAndRoot(
69 p_playlist, p_parent->i_id,
70 p_playlist->p_root_category,
71 VLC_FALSE /* Only non-node */ );
72 if( !p_item_in_category )
74 /* Item may have been removed */
79 b_play = b_play && p_item_in_category == p_playlist->status.p_item;
81 /* If you want to use vlc_input_item_subitem_added event,
82 * you must explicitely create nodes */
83 assert( p_item_in_category->i_children != -1 );
85 playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
86 PLAYLIST_APPEND | PLAYLIST_SPREPARSE , PLAYLIST_END,
87 NULL, NULL, VLC_TRUE );
91 playlist_item_t *p_pl_item, *p_new_pl_item;
92 p_pl_item = playlist_ItemFindFromInputAndRoot( p_playlist,
93 p_child->i_id, p_playlist->p_root_category, VLC_FALSE );
94 p_new_pl_item = playlist_ItemToNode( p_playlist, p_pl_item,
96 p_new_pl_item->p_input->i_type = ITEM_TYPE_NODE;
101 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
102 VLC_TRUE, p_item_in_category, NULL );
110 /*****************************************************************************
111 * Listen to vlc_InputItemAddSubItem event
112 *****************************************************************************/
113 static void install_input_item_observer( playlist_item_t * p_item )
115 vlc_event_attach( &p_item->p_input->event_manager,
116 vlc_InputItemSubItemAdded,
117 input_item_subitem_added,
121 static void uninstall_input_item_observer( playlist_item_t * p_item )
123 vlc_event_detach( &p_item->p_input->event_manager,
124 vlc_InputItemSubItemAdded,
125 input_item_subitem_added,
130 /*****************************************************************************
131 * Playlist item creation
132 *****************************************************************************/
133 playlist_item_t * playlist_ItemNewWithType( vlc_object_t *p_obj,
135 const char *psz_name,
137 const char *const *ppsz_options,
138 int i_duration, int i_type )
140 input_item_t *p_input;
141 if( psz_uri == NULL ) return NULL;
142 p_input = input_ItemNewWithType( p_obj, psz_uri,
143 psz_name, i_options, ppsz_options,
144 i_duration, i_type );
145 return playlist_ItemNewFromInput( p_obj, p_input );
148 playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
149 input_item_t *p_input )
151 DECMALLOC_NULL( p_item, playlist_item_t );
152 playlist_t *p_playlist = pl_Yield( p_obj );
154 p_item->p_input = p_input;
155 vlc_gc_incref( p_item->p_input );
157 p_item->i_id = ++p_playlist->i_last_playlist_id;
159 p_item->p_parent = NULL;
160 p_item->i_children = -1;
161 p_item->pp_children = NULL;
163 p_item->p_playlist = p_playlist;
165 install_input_item_observer( p_item );
167 pl_Release( p_item->p_playlist );
172 /***************************************************************************
173 * Playlist item destruction
174 ***************************************************************************/
176 /** Delete a playlist item and detach its input item */
177 int playlist_ItemDelete( playlist_item_t *p_item )
179 uninstall_input_item_observer( p_item );
181 vlc_gc_decref( p_item->p_input );
186 /** Remove an input item when it appears from a root playlist item */
187 static int DeleteFromInput( playlist_t *p_playlist, int i_input_id,
188 playlist_item_t *p_root, vlc_bool_t b_do_stop )
191 for( i = 0 ; i< p_root->i_children ; i++ )
193 if( p_root->pp_children[i]->i_children == -1 &&
194 p_root->pp_children[i]->p_input->i_id == i_input_id )
196 DeleteInner( p_playlist, p_root->pp_children[i], b_do_stop );
199 else if( p_root->pp_children[i]->i_children >= 0 )
201 int i_ret = DeleteFromInput( p_playlist, i_input_id,
202 p_root->pp_children[i], b_do_stop );
203 if( i_ret == VLC_SUCCESS ) return VLC_SUCCESS;
209 /** Remove an input item when it appears from a root playlist item */
210 int playlist_DeleteInputInParent( playlist_t *p_playlist, int i_input_id,
211 playlist_item_t *p_root, vlc_bool_t b_locked )
214 if( !b_locked ) PL_LOCK;
215 i_ret = DeleteFromInput( p_playlist, i_input_id,
217 if( !b_locked ) PL_UNLOCK;
221 /** Remove an input item from ONELEVEL and CATEGORY */
222 int playlist_DeleteFromInput( playlist_t *p_playlist, int i_input_id,
223 vlc_bool_t b_locked )
226 if( !b_locked ) PL_LOCK;
227 i_ret1 = DeleteFromInput( p_playlist, i_input_id,
228 p_playlist->p_root_category, VLC_TRUE );
229 i_ret2 = DeleteFromInput( p_playlist, i_input_id,
230 p_playlist->p_root_onelevel, VLC_TRUE );
231 if( !b_locked ) PL_UNLOCK;
232 return ( i_ret1 == VLC_SUCCESS || i_ret2 == VLC_SUCCESS ) ?
233 VLC_SUCCESS : VLC_ENOITEM;
236 void playlist_Clear( playlist_t * p_playlist, vlc_bool_t b_locked )
238 if( !b_locked ) PL_LOCK;
239 playlist_NodeEmpty( p_playlist, p_playlist->p_local_category, VLC_TRUE );
240 playlist_NodeEmpty( p_playlist, p_playlist->p_local_onelevel, VLC_TRUE );
241 if( !b_locked ) PL_UNLOCK;
244 /** Remove a playlist item from the playlist, given its id
245 * This function is to be used only by the playlist */
246 int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
248 playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,
250 if( !p_item ) return VLC_EGENERIC;
251 return DeleteInner( p_playlist, p_item, VLC_TRUE );
254 /***************************************************************************
255 * Playlist item addition
256 ***************************************************************************/
257 /** Add an item to the playlist or the media library
258 * \param p_playlist the playlist to add into
259 * \param psz_uri the mrl to add to the playlist
260 * \param psz_name a text giving a name or description of this item
261 * \param i_mode the mode used when adding
262 * \param i_pos the position in the playlist where to add. If this is
263 * PLAYLIST_END the item will be added at the end of the playlist
264 * regardless of its size
265 * \param b_playlist TRUE for playlist, FALSE for media library
266 * \return The id of the playlist item
268 int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
269 const char *psz_name, int i_mode, int i_pos,
270 vlc_bool_t b_playlist, vlc_bool_t b_locked )
272 return playlist_AddExt( p_playlist, psz_uri, psz_name,
273 i_mode, i_pos, -1, NULL, 0, b_playlist, b_locked );
277 * Add a MRL into the playlist or the media library, duration and options given
279 * \param p_playlist the playlist to add into
280 * \param psz_uri the mrl to add to the playlist
281 * \param psz_name a text giving a name or description of this item
282 * \param i_mode the mode used when adding
283 * \param i_pos the position in the playlist where to add. If this is
284 * PLAYLIST_END the item will be added at the end of the playlist
285 * regardless of its size
286 * \param i_duration length of the item in milliseconds.
287 * \param ppsz_options an array of options
288 * \param i_options the number of options
289 * \param b_playlist TRUE for playlist, FALSE for media library
290 * \return The id of the playlist item
292 int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
293 const char *psz_name, int i_mode, int i_pos,
294 mtime_t i_duration, const char *const *ppsz_options,
295 int i_options, vlc_bool_t b_playlist, vlc_bool_t b_locked )
298 input_item_t *p_input = input_ItemNewExt( p_playlist, psz_uri, psz_name,
299 i_options, ppsz_options,
302 i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
304 int i_id = i_ret == VLC_SUCCESS ? p_input->i_id : -1;
306 vlc_gc_decref( p_input );
311 /** Add an input item to the playlist node */
312 int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
313 int i_mode, int i_pos, vlc_bool_t b_playlist,
314 vlc_bool_t b_locked )
316 playlist_item_t *p_item_cat, *p_item_one;
318 if( !p_playlist->b_doing_ml )
319 PL_DEBUG( "adding item `%s' ( %s )", p_input->psz_name,
322 if( !b_locked ) PL_LOCK;
324 /* Add to ONELEVEL */
325 p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
326 if( p_item_one == NULL ) return VLC_ENOMEM;
327 AddItem( p_playlist, p_item_one,
328 b_playlist ? p_playlist->p_local_onelevel :
329 p_playlist->p_ml_onelevel , i_mode, i_pos );
331 /* Add to CATEGORY */
332 p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
333 if( p_item_cat == NULL ) return VLC_ENOMEM;
334 AddItem( p_playlist, p_item_cat,
335 b_playlist ? p_playlist->p_local_category :
336 p_playlist->p_ml_category , i_mode, i_pos );
338 GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
340 if( !b_locked ) PL_UNLOCK;
344 /** Add an input item to p_direct_parent in the category tree, and to the
345 * matching top category in onelevel **/
346 int playlist_BothAddInput( playlist_t *p_playlist,
347 input_item_t *p_input,
348 playlist_item_t *p_direct_parent,
349 int i_mode, int i_pos,
350 int *i_cat, int *i_one, vlc_bool_t b_locked )
352 playlist_item_t *p_item_cat, *p_item_one, *p_up;
355 if( !b_locked ) PL_LOCK;
357 /* Add to category */
358 p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
359 if( p_item_cat == NULL ) return VLC_ENOMEM;
360 AddItem( p_playlist, p_item_cat, p_direct_parent, i_mode, i_pos );
362 /* Add to onelevel */
363 /**Â \todo make a faster case for ml import */
364 p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
365 if( p_item_one == NULL ) return VLC_ENOMEM;
367 p_up = p_direct_parent;
368 while( p_up->p_parent != p_playlist->p_root_category )
370 p_up = p_up->p_parent;
372 for( i_top = 0 ; i_top < p_playlist->p_root_onelevel->i_children; i_top++ )
374 if( p_playlist->p_root_onelevel->pp_children[i_top]->p_input->i_id ==
375 p_up->p_input->i_id )
377 AddItem( p_playlist, p_item_one,
378 p_playlist->p_root_onelevel->pp_children[i_top],
383 GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
385 if( i_cat ) *i_cat = p_item_cat->i_id;
386 if( i_one ) *i_one = p_item_one->i_id;
388 if( !b_locked ) PL_UNLOCK;
392 /** Add an input item to a given node */
393 playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
394 input_item_t *p_input,
395 playlist_item_t *p_parent,
396 int i_mode, int i_pos,
397 vlc_bool_t b_locked )
399 playlist_item_t *p_item;
401 assert( p_parent && p_parent->i_children != -1 );
403 if( !b_locked ) PL_LOCK;
405 p_item = playlist_ItemNewFromInput( p_playlist, p_input );
406 if( p_item == NULL ) return NULL;
407 AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
409 if( !b_locked ) PL_UNLOCK;
414 /*****************************************************************************
415 * Playlist item misc operations
416 *****************************************************************************/
419 * Transform an item to a node. Return the node in the category tree, or NULL
422 playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
423 playlist_item_t *p_item,
424 vlc_bool_t b_locked )
427 playlist_item_t *p_item_in_category;
429 * Find the input in CATEGORY.
431 * - change it to node
432 * - we'll return it at the end
433 * - If we are a direct child of onelevel root, change to node, else
434 * delete the input from ONELEVEL
435 * - If we don't find it, just change to node (we are probably in VLM)
438 * If we were in ONELEVEL, we thus retrieve the node in CATEGORY (will be
439 * useful for later BothAddInput )
442 if( !b_locked ) PL_LOCK;
444 /* Fast track the media library, no time to loose */
445 if( p_item == p_playlist->p_ml_category ) {
446 if( !b_locked ) PL_UNLOCK;
450 /** \todo First look if we don't already have it */
451 p_item_in_category = playlist_ItemFindFromInputAndRoot(
452 p_playlist, p_item->p_input->i_id,
453 p_playlist->p_root_category,
456 if( p_item_in_category )
458 playlist_item_t *p_item_in_one = playlist_ItemFindFromInputAndRoot(
459 p_playlist, p_item->p_input->i_id,
460 p_playlist->p_root_onelevel,
462 assert( p_item_in_one );
464 /* We already have it, and there is nothing more to do */
465 ChangeToNode( p_playlist, p_item_in_category );
467 /* Item in one is a root, change it to node */
468 if( p_item_in_one->p_parent == p_playlist->p_root_onelevel )
469 ChangeToNode( p_playlist, p_item_in_one );
472 DeleteFromInput( p_playlist, p_item_in_one->p_input->i_id,
473 p_playlist->p_root_onelevel, VLC_FALSE );
475 p_playlist->b_reset_currently_playing = VLC_TRUE;
476 vlc_cond_signal( &p_playlist->object_wait );
477 var_SetInteger( p_playlist, "item-change", p_item_in_category->
479 if( !b_locked ) PL_UNLOCK;
480 return p_item_in_category;
484 ChangeToNode( p_playlist, p_item );
485 if( !b_locked ) PL_UNLOCK;
490 /** Find an item within a root, given its input id.
491 * \return the first found item, or NULL if not found
493 playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
495 playlist_item_t *p_root,
496 vlc_bool_t b_items_only )
499 for( i = 0 ; i< p_root->i_children ; i++ )
501 if( ( b_items_only ? p_root->pp_children[i]->i_children == -1 : 1 ) &&
502 p_root->pp_children[i]->p_input->i_id == i_input_id )
504 return p_root->pp_children[i];
506 else if( p_root->pp_children[i]->i_children >= 0 )
508 playlist_item_t *p_search =
509 playlist_ItemFindFromInputAndRoot( p_playlist, i_input_id,
510 p_root->pp_children[i],
512 if( p_search ) return p_search;
519 static int TreeMove( playlist_t *p_playlist, playlist_item_t *p_item,
520 playlist_item_t *p_node, int i_newpos )
523 playlist_item_t *p_detach = p_item->p_parent;
526 if( p_node->i_children == -1 ) return VLC_EGENERIC;
528 for( j = 0; j < p_detach->i_children; j++ )
530 if( p_detach->pp_children[j] == p_item ) break;
532 REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, j );
534 /* Attach to new parent */
535 INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item );
536 p_item->p_parent = p_node;
544 * This function must be entered with the playlist lock
546 * \param p_playlist the playlist
547 * \param p_item the item to move
548 * \param p_node the new parent of the item
549 * \param i_newpos the new position under this new parent
550 * \return VLC_SUCCESS or an error
552 int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
553 playlist_item_t *p_node, int i_newpos )
556 /* Drop on a top level node. Move in the two trees */
557 if( p_node->p_parent == p_playlist->p_root_category ||
558 p_node->p_parent == p_playlist->p_root_onelevel )
560 /* Fixme: avoid useless lookups but we need some clean helpers */
562 /* Fixme: if we try to move a node on a top-level node, it will
563 * fail because the node doesn't exist in onelevel and we will
564 * do some shit in onelevel. We should recursively move all items
566 playlist_item_t *p_node_onelevel;
567 playlist_item_t *p_item_onelevel;
568 p_node_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
569 p_node->p_input->i_id,
570 p_playlist->p_root_onelevel,
572 p_item_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
573 p_item->p_input->i_id,
574 p_playlist->p_root_onelevel,
576 if( p_node_onelevel && p_item_onelevel )
577 TreeMove( p_playlist, p_item_onelevel, p_node_onelevel, 0 );
580 playlist_item_t *p_node_category;
581 playlist_item_t *p_item_category;
582 p_node_category = playlist_ItemFindFromInputAndRoot( p_playlist,
583 p_node->p_input->i_id,
584 p_playlist->p_root_category,
586 p_item_category = playlist_ItemFindFromInputAndRoot( p_playlist,
587 p_item->p_input->i_id,
588 p_playlist->p_root_category,
590 if( p_node_category && p_item_category )
591 TreeMove( p_playlist, p_item_category, p_node_category, 0 );
596 i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
597 p_playlist->b_reset_currently_playing = VLC_TRUE;
598 vlc_cond_signal( &p_playlist->object_wait );
602 /** Send a notification that an item has been added to a node */
603 void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
604 int i_node_id, vlc_bool_t b_signal )
607 playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t));
608 p_add->i_item = i_item_id;
609 p_add->i_node = i_node_id;
610 val.p_address = p_add;
611 p_playlist->b_reset_currently_playing = VLC_TRUE;
613 vlc_cond_signal( &p_playlist->object_wait );
614 var_Set( p_playlist, "item-append", val );
618 /*****************************************************************************
619 * Playlist item accessors
620 *****************************************************************************/
622 /** Set the name of a playlist item */
623 int playlist_ItemSetName( playlist_item_t *p_item, const char *psz_name )
625 if( psz_name && p_item )
627 input_item_SetName( p_item->p_input, psz_name );
633 /***************************************************************************
634 * The following functions are local
635 ***************************************************************************/
637 /* Enqueue an item for preparsing, and play it, if needed */
638 static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
639 playlist_item_t *p_item_cat,
640 playlist_item_t *p_item_one )
642 if( (i_mode & PLAYLIST_GO ) )
644 playlist_item_t *p_parent = p_item_one;
645 playlist_item_t *p_toplay = NULL;
648 if( p_parent == p_playlist->p_root_category )
650 p_toplay = p_item_cat; break;
652 else if( p_parent == p_playlist->p_root_onelevel )
654 p_toplay = p_item_one; break;
656 p_parent = p_parent->p_parent;
659 p_playlist->request.b_request = VLC_TRUE;
660 p_playlist->request.i_skip = 0;
661 p_playlist->request.p_item = p_toplay;
662 if( p_playlist->p_input )
663 input_StopThread( p_playlist->p_input );
664 p_playlist->request.i_status = PLAYLIST_RUNNING;
665 vlc_cond_signal( &p_playlist->object_wait );
667 /* Preparse if PREPARSE or SPREPARSE & not enough meta */
668 char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
669 char *psz_album = input_item_GetAlbum( p_item_cat->p_input );
670 if( p_playlist->b_auto_preparse &&
671 (i_mode & PLAYLIST_PREPARSE ||
672 ( i_mode & PLAYLIST_SPREPARSE &&
673 ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) )
675 playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input );
676 /* If we already have it, signal it */
677 else if( !EMPTY_STR( psz_artist ) && !EMPTY_STR( psz_album ) )
678 input_item_SetPreparsed( p_item_cat->p_input, VLC_TRUE );
683 /* Add the playlist item to the requested node and fire a notification */
684 static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
685 playlist_item_t *p_node, int i_mode, int i_pos )
687 ARRAY_APPEND(p_playlist->items, p_item);
688 ARRAY_APPEND(p_playlist->all_items, p_item);
689 p_playlist->i_enabled ++;
691 if( i_pos == PLAYLIST_END )
692 playlist_NodeAppend( p_playlist, p_item, p_node );
694 playlist_NodeInsert( p_playlist, p_item, p_node, i_pos );
696 if( !p_playlist->b_doing_ml )
697 playlist_SendAddNotify( p_playlist, p_item->i_id, p_node->i_id,
698 !( i_mode & PLAYLIST_NO_REBUILD ) );
701 /* Actually convert an item to a node */
702 static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item )
705 if( p_item->i_children == -1 )
706 p_item->i_children = 0;
708 /* Remove it from the array of available items */
709 ARRAY_BSEARCH( p_playlist->items,->i_id, int, p_item->i_id, i );
711 ARRAY_REMOVE( p_playlist->items, i );
714 /* Do the actual removal */
715 static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
719 int i_id = p_item->i_id;
720 vlc_bool_t b_delay_deletion = VLC_FALSE;
722 if( p_item->i_children > -1 )
724 return playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
726 p_playlist->b_reset_currently_playing = VLC_TRUE;
727 var_SetInteger( p_playlist, "item-deleted", i_id );
729 /* Remove the item from the bank */
730 ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i );
732 ARRAY_REMOVE( p_playlist->all_items, i );
734 /* Check if it is the current item */
735 if( p_playlist->status.p_item == p_item )
737 /* Hack we don't call playlist_Control for lock reasons */
740 p_playlist->request.i_status = PLAYLIST_STOPPED;
741 p_playlist->request.b_request = VLC_TRUE;
742 p_playlist->request.p_item = NULL;
743 msg_Info( p_playlist, "stopping playback" );
744 vlc_cond_signal( &p_playlist->object_wait );
746 b_delay_deletion = VLC_TRUE;
749 PL_DEBUG( "deleting item `%s'", p_item->p_input->psz_name );
751 /* Remove the item from its parent */
752 playlist_NodeRemoveItem( p_playlist, p_item, p_item->p_parent );
754 if( !b_delay_deletion )
755 playlist_ItemDelete( p_item );
758 PL_DEBUG( "marking %s for further deletion", PLI_NAME( p_item ) );
759 p_item->i_flags |= PLAYLIST_REMOVE_FLAG;