Skip to content

Commit

Permalink
playlist: pass playlist item as "playlist-item-deleted" value
Browse files Browse the repository at this point in the history
This makes deletion and appending somewhat more consistent.
  • Loading branch information
Rémi Denis-Courmont committed Nov 15, 2016
1 parent 9bd1235 commit 705dc65
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/vlc_playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ struct intf_thread_t;
* item being played.
*
* - "playlist-item-append": It will contain a pointer to a playlist_item_t.
* - "playlist-item-deleted": It will contain the playlist_item_t->i_id of a
* deleted playlist_item_t.
* - "playlist-item-deleted": It will contain a pointer to the playlist_item_t
* about to be deleted.
*
* - "leaf-to-parent": It will contain the playlist_item_t->i_id of an item that is transformed
* into a node.
Expand Down
3 changes: 2 additions & 1 deletion modules/gui/macosx/VLCPLModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ static int VLCPLItemRemoved(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
@autoreleasepool {
NSNumber *o_val = [NSNumber numberWithInt:new_val.i_int];
playlist_item_t *p_item = new_val.p_address;
NSNumber *o_val = [NSNumber numberWithInt:p_item->i_id];
VLCPLModel *model = (__bridge VLCPLModel*)param;
[model performSelectorOnMainThread:@selector(VLCPLItemRemoved:) withObject:o_val waitUntilDone:NO];

Expand Down
3 changes: 2 additions & 1 deletion modules/gui/qt/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,8 +1248,9 @@ int MainInputManager::PLItemRemoved( vlc_object_t *obj, const char *,
{
playlist_t *pl = (playlist_t *) obj;
MainInputManager *mim = static_cast<MainInputManager*>(data);
playlist_item_t *item = static_cast<playlist_item_t *>( cur.p_address );

PLEvent *event = new PLEvent( PLEvent::PLItemRemoved, cur.i_int, 0 );
PLEvent *event = new PLEvent( PLEvent::PLItemRemoved, item->i_id, 0 );
QApplication::postEvent( mim, event );
// can't use playlist_IsEmpty( ) as it isn't true yet
if ( pl->items.i_size == 1 ) // lock is held
Expand Down
4 changes: 2 additions & 2 deletions modules/gui/skins2/src/vlcproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
(void)pObj; (void)pVariable; (void)oldVal;
VlcProc *pThis = (VlcProc*)pParam;

int i_id = newVal.i_int;
playlist_item_t *item = static_cast<playlist_item_t *>(newVal.p_address);
CmdPlaytreeDelete *pCmdTree =
new CmdPlaytreeDelete( pThis->getIntf(), i_id);
new CmdPlaytreeDelete( pThis->getIntf(), item->i_id);

// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
Expand Down
4 changes: 1 addition & 3 deletions src/playlist/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,8 @@ static void VariablesInit( playlist_t *p_playlist )
var_Create( p_playlist, "item-change", VLC_VAR_ADDRESS );
var_Create( p_playlist, "leaf-to-parent", VLC_VAR_INTEGER );

var_Create( p_playlist, "playlist-item-deleted", VLC_VAR_INTEGER );
var_SetInteger( p_playlist, "playlist-item-deleted", -1 );

var_Create( p_playlist, "playlist-item-append", VLC_VAR_ADDRESS );
var_Create( p_playlist, "playlist-item-deleted", VLC_VAR_ADDRESS );

var_Create( p_playlist, "input-current", VLC_VAR_ADDRESS );

Expand Down
2 changes: 1 addition & 1 deletion src/playlist/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
pl_priv(p_playlist)->b_reset_currently_playing = true;

int i;
var_SetInteger( p_playlist, "playlist-item-deleted", p_root->i_id );
var_SetAddress( p_playlist, "playlist-item-deleted", p_root );
ARRAY_BSEARCH( pl_priv(p_playlist)->all_items, ->i_id, int, p_root->i_id, i );
if( i != -1 )
ARRAY_REMOVE( pl_priv(p_playlist)->all_items, i );
Expand Down

0 comments on commit 705dc65

Please sign in to comment.