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

playlist_DeleteFromInput: pass the input item rather than its ID

parent bbba5c6f
...@@ -111,7 +111,7 @@ TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t); ...@@ -111,7 +111,7 @@ TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t);
* Generally speaking, playlist_NodeAddInput should not be used in newer code, it * Generally speaking, playlist_NodeAddInput should not be used in newer code, it
* will maybe become useful again when we merge VLM; * will maybe become useful again when we merge VLM;
* *
* To delete an item, use playlist_DeleteFromInput( input_id ) which will * To delete an item, use playlist_DeleteFromInput( p_item ) which will
* remove all occurrences of the input in both trees * remove all occurrences of the input in both trees
* *
* *
...@@ -322,7 +322,7 @@ VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char ...@@ -322,7 +322,7 @@ VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char
********************************************************/ ********************************************************/
/*************************** Item deletion **************************/ /*************************** Item deletion **************************/
VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, int, bool ) ); VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, input_item_t *, bool ) );
/******************** Item addition ********************/ /******************** Item addition ********************/
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int, bool, bool ) ); VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int, bool, bool ) );
......
...@@ -514,7 +514,7 @@ DBUS_METHOD( DelTrack ) ...@@ -514,7 +514,7 @@ DBUS_METHOD( DelTrack )
if( i_position < p_playlist->current.i_size ) if( i_position < p_playlist->current.i_size )
{ {
playlist_DeleteFromInput( p_playlist, playlist_DeleteFromInput( p_playlist,
p_playlist->current.p_elems[i_position]->p_input->i_id, p_playlist->current.p_elems[i_position]->p_input,
pl_Locked ); pl_Locked );
} }
PL_UNLOCK; PL_UNLOCK;
......
...@@ -381,7 +381,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -381,7 +381,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
p_items[i] ); p_items[i] );
if( p_item ) if( p_item )
playlist_DeleteFromInput( p_sys->p_playlist, playlist_DeleteFromInput( p_sys->p_playlist,
p_item->p_input->i_id, p_item->p_input,
false ); false );
} }
...@@ -424,7 +424,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -424,7 +424,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
p_sys->p_playlist->items.p_elems[i]->i_id ); p_sys->p_playlist->items.p_elems[i]->i_id );
playlist_DeleteFromInput( p_sys->p_playlist, playlist_DeleteFromInput( p_sys->p_playlist,
p_sys->p_playlist->items.p_elems[i]->p_input->i_id, p_sys->p_playlist->items.p_elems[i]->p_input,
false ); false );
} }
} }
......
...@@ -875,7 +875,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -875,7 +875,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
if( p_item ) if( p_item )
{ {
playlist_DeleteFromInput( p_sys->p_playlist, playlist_DeleteFromInput( p_sys->p_playlist,
p_item->p_input->i_id, pl_Locked ); p_item->p_input, pl_Locked );
msg_Dbg( p_intf, "requested playlist delete: %d", i_id ); msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
} }
else else
......
...@@ -968,7 +968,7 @@ ...@@ -968,7 +968,7 @@
playlist_NodeDelete( p_playlist, p_item, true, false ); playlist_NodeDelete( p_playlist, p_item, true, false );
} }
else else
playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, pl_Locked ); playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
} }
PL_UNLOCK; PL_UNLOCK;
......
...@@ -656,7 +656,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key ) ...@@ -656,7 +656,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
if( p_item->i_children == -1 ) if( p_item->i_children == -1 )
{ {
playlist_DeleteFromInput( p_playlist, playlist_DeleteFromInput( p_playlist,
p_item->p_input->i_id, pl_Locked ); p_item->p_input, pl_Locked );
} }
else else
{ {
......
...@@ -719,7 +719,7 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList ) ...@@ -719,7 +719,7 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
return; return;
} }
if( p_item->i_children == -1 ) if( p_item->i_children == -1 )
playlist_DeleteFromInput( p_playlist, item->i_input_id, pl_Locked ); playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
else else
playlist_NodeDelete( p_playlist, p_item, true, false ); playlist_NodeDelete( p_playlist, p_item, true, false );
/* And finally, remove it from the tree */ /* And finally, remove it from the tree */
......
...@@ -74,7 +74,7 @@ void Playtree::delSelected() ...@@ -74,7 +74,7 @@ void Playtree::delSelected()
if( p_item->i_children == -1 ) if( p_item->i_children == -1 )
{ {
playlist_DeleteFromInput( getIntf()->p_sys->p_playlist, playlist_DeleteFromInput( getIntf()->p_sys->p_playlist,
p_item->p_input->i_id, pl_Locked ); p_item->p_input, pl_Locked );
it2 = getNextVisibleItem( it ) ; it2 = getNextVisibleItem( it ) ;
it->parent()->removeChild( it ); it->parent()->removeChild( it );
it = it2; it = it2;
......
...@@ -700,7 +700,7 @@ void Playlist::UpdateItem( int i ) ...@@ -700,7 +700,7 @@ void Playlist::UpdateItem( int i )
/********************************************************************** /**********************************************************************
* Private functions * Private functions
**********************************************************************/ **********************************************************************/
void Playlist::DeleteItem( int item ) void Playlist::DeleteItem( input_item_t *item )
{ {
playlist_t *p_playlist = pl_Hold( p_intf ); playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
......
...@@ -218,12 +218,12 @@ int playlist_ItemRelease( playlist_item_t *p_item ) ...@@ -218,12 +218,12 @@ int playlist_ItemRelease( playlist_item_t *p_item )
* *
* Remove an input item when it appears from a root playlist item * Remove an input item when it appears from a root playlist item
* \param p_playlist playlist object * \param p_playlist playlist object
* \param i_input_id id of the input to delete * \param p_input the input to delete
* \param p_root root playlist item * \param p_root root playlist item
* \param b_do_stop must stop or not the playlist * \param b_do_stop must stop or not the playlist
* \return VLC_SUCCESS or VLC_EGENERIC * \return VLC_SUCCESS or VLC_EGENERIC
*/ */
static int DeleteFromInput( playlist_t *p_playlist, int i_input_id, static int DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input,
playlist_item_t *p_root, bool b_do_stop ) playlist_item_t *p_root, bool b_do_stop )
{ {
int i; int i;
...@@ -231,14 +231,14 @@ static int DeleteFromInput( playlist_t *p_playlist, int i_input_id, ...@@ -231,14 +231,14 @@ static int DeleteFromInput( playlist_t *p_playlist, int i_input_id,
for( i = 0 ; i< p_root->i_children ; i++ ) for( i = 0 ; i< p_root->i_children ; i++ )
{ {
if( p_root->pp_children[i]->i_children == -1 && if( p_root->pp_children[i]->i_children == -1 &&
p_root->pp_children[i]->p_input->i_id == i_input_id ) p_root->pp_children[i]->p_input == p_input )
{ {
DeleteInner( p_playlist, p_root->pp_children[i], b_do_stop ); DeleteInner( p_playlist, p_root->pp_children[i], b_do_stop );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
else if( p_root->pp_children[i]->i_children >= 0 ) else if( p_root->pp_children[i]->i_children >= 0 )
{ {
int i_ret = DeleteFromInput( p_playlist, i_input_id, int i_ret = DeleteFromInput( p_playlist, p_input,
p_root->pp_children[i], b_do_stop ); p_root->pp_children[i], b_do_stop );
if( i_ret == VLC_SUCCESS ) return VLC_SUCCESS; if( i_ret == VLC_SUCCESS ) return VLC_SUCCESS;
} }
...@@ -251,18 +251,18 @@ static int DeleteFromInput( playlist_t *p_playlist, int i_input_id, ...@@ -251,18 +251,18 @@ static int DeleteFromInput( playlist_t *p_playlist, int i_input_id,
* *
* Remove an input item when it appears from a root playlist item * Remove an input item when it appears from a root playlist item
* \param p_playlist playlist object * \param p_playlist playlist object
* \param i_input_id id of the input to delete * \param p_input the input to delete
* \param p_root root playlist item * \param p_root root playlist item
* \param b_locked TRUE if the playlist is locked * \param b_locked TRUE if the playlist is locked
* \return VLC_SUCCESS or VLC_EGENERIC * \return VLC_SUCCESS or VLC_EGENERIC
*/ */
int playlist_DeleteFromInputInParent( playlist_t *p_playlist, int i_input_id, int playlist_DeleteFromInputInParent( playlist_t *p_playlist,
input_item_t *p_item,
playlist_item_t *p_root, bool b_locked ) playlist_item_t *p_root, bool b_locked )
{ {
int i_ret; int i_ret;
PL_LOCK_IF( !b_locked ); PL_LOCK_IF( !b_locked );
i_ret = DeleteFromInput( p_playlist, i_input_id, i_ret = DeleteFromInput( p_playlist, p_item, p_root, true );
p_root, true );
PL_UNLOCK_IF( !b_locked ); PL_UNLOCK_IF( !b_locked );
return i_ret; return i_ret;
} }
...@@ -272,18 +272,18 @@ int playlist_DeleteFromInputInParent( playlist_t *p_playlist, int i_input_id, ...@@ -272,18 +272,18 @@ int playlist_DeleteFromInputInParent( playlist_t *p_playlist, int i_input_id,
* *
* Remove an input item from ONELEVEL and CATEGORY * Remove an input item from ONELEVEL and CATEGORY
* \param p_playlist playlist object * \param p_playlist playlist object
* \param i_input_id id of the input to delete * \param p_input the input to delete
* \param b_locked TRUE if the playlist is locked * \param b_locked TRUE if the playlist is locked
* \return VLC_SUCCESS or VLC_ENOITEM * \return VLC_SUCCESS or VLC_ENOITEM
*/ */
int playlist_DeleteFromInput( playlist_t *p_playlist, int i_input_id, int playlist_DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input,
bool b_locked ) bool b_locked )
{ {
int i_ret1, i_ret2; int i_ret1, i_ret2;
PL_LOCK_IF( !b_locked ); PL_LOCK_IF( !b_locked );
i_ret1 = DeleteFromInput( p_playlist, i_input_id, i_ret1 = DeleteFromInput( p_playlist, p_input,
p_playlist->p_root_category, true ); p_playlist->p_root_category, true );
i_ret2 = DeleteFromInput( p_playlist, i_input_id, i_ret2 = DeleteFromInput( p_playlist, p_input,
p_playlist->p_root_onelevel, true ); p_playlist->p_root_onelevel, true );
PL_UNLOCK_IF( !b_locked ); PL_UNLOCK_IF( !b_locked );
return ( i_ret1 == VLC_SUCCESS || i_ret2 == VLC_SUCCESS ) ? return ( i_ret1 == VLC_SUCCESS || i_ret2 == VLC_SUCCESS ) ?
...@@ -620,7 +620,7 @@ static playlist_item_t *ItemToNode( playlist_t *p_playlist, ...@@ -620,7 +620,7 @@ static playlist_item_t *ItemToNode( playlist_t *p_playlist,
if( p_prev_status_item ) if( p_prev_status_item )
set_current_status_item( p_playlist, p_prev_status_item ); set_current_status_item( p_playlist, p_prev_status_item );
} }
DeleteFromInput( p_playlist, p_item_in_one->p_input->i_id, DeleteFromInput( p_playlist, p_item_in_one->p_input,
p_playlist->p_root_onelevel, false ); p_playlist->p_root_onelevel, false );
} }
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
......
...@@ -138,7 +138,8 @@ playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist, ...@@ -138,7 +138,8 @@ playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
int i_input_id, playlist_item_t *p_root, int i_input_id, playlist_item_t *p_root,
bool ); bool );
int playlist_DeleteFromInputInParent( playlist_t *, int, playlist_item_t *, bool ); int playlist_DeleteFromInputInParent( playlist_t *, input_item_t *,
playlist_item_t *, bool );
int playlist_DeleteFromItemId( playlist_t*, int ); int playlist_DeleteFromItemId( playlist_t*, int );
int playlist_ItemRelease( playlist_item_t * ); int playlist_ItemRelease( playlist_item_t * );
......
...@@ -219,7 +219,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d ...@@ -219,7 +219,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
playlist_NodeDelete( p_parent->p_playlist, p_pl_item, true, false ); playlist_NodeDelete( p_parent->p_playlist, p_pl_item, true, false );
else else
/* Delete the non-node item normally */ /* Delete the non-node item normally */
playlist_DeleteFromInputInParent( p_parent->p_playlist, p_input->i_id, playlist_DeleteFromInputInParent( p_parent->p_playlist, p_input,
p_parent, pl_Locked ); p_parent, pl_Locked );
playlist_Unlock( p_parent->p_playlist ); playlist_Unlock( p_parent->p_playlist );
......
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