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

playlist: remove position parameter to playlist_Add*

This removes the insertion offset parameter to playlist_Add(),
playlist_AddExt() and playlist_AddInput().

intf_InsertItem() was the only occurrence where the offset was zero,
a side effect of how the command line is parsed backward. This is now
done explicitly with playlist_NodeAddInput().

A non-zero positive offset made no sense, since:
 - the number of children of a node can change asynchronously while the
   playlist lock,
 - the back-end asserted or triggered undefined behaviour if the offset
   was out of range.
DBus was the only occurrence of this bug (see also #17451 comment:4),
and has been fixed in an earlier change.

In all remaining call sites, the offset was PLAYLIST_END. This removes
the parameter which would otherwise constitute a useless constant.
parent bbe53b4f
......@@ -321,9 +321,9 @@ VLC_API int playlist_ServicesDiscoveryControl( playlist_t *, const char *, int,
********************************************************/
/******************** Item addition ********************/
VLC_API int playlist_Add( playlist_t *, const char *, const char *, int, int, bool );
VLC_API int playlist_AddExt( playlist_t *, const char *, const char *, int, int, int, const char *const *, unsigned, bool );
VLC_API int playlist_AddInput( playlist_t *, input_item_t *, int, int, bool );
VLC_API int playlist_Add( playlist_t *, const char *, const char *, int, bool );
VLC_API int playlist_AddExt( playlist_t *, const char *, const char *, int, int, const char *const *, unsigned, bool );
VLC_API int playlist_AddInput( playlist_t *, input_item_t *, int, bool );
VLC_API playlist_item_t * playlist_NodeAddInput( playlist_t *, input_item_t *, playlist_item_t *, int, int );
VLC_API int playlist_NodeAddCopy( playlist_t *, playlist_item_t *, playlist_item_t *, int );
......
......@@ -229,7 +229,7 @@ DBUS_METHOD( OpenUri )
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
playlist_Add( PL, psz_mrl, NULL, PLAYLIST_GO, PLAYLIST_END, true );
playlist_Add( PL, psz_mrl, NULL, PLAYLIST_GO, true );
REPLY_SEND;
}
......
......@@ -1297,7 +1297,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
{
msg_rc( "Trying to add %s to playlist.", newval.psz_string );
int i_ret = playlist_AddInput( p_playlist, p_item,
PLAYLIST_GO, PLAYLIST_END, true );
PLAYLIST_GO, true );
vlc_gc_decref( p_item );
if( i_ret != VLC_SUCCESS )
{
......@@ -1314,7 +1314,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
{
msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
if( playlist_AddInput( p_playlist, p_item,
0, PLAYLIST_END, true ) != VLC_SUCCESS )
0, true ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
......
......@@ -102,7 +102,6 @@ static LRESULT CALLBACK WMCOPYWNDPROC(HWND hwnd, UINT uMsg,
(psz_URI != NULL) ? psz_URI : ppsz_argv[i_opt],
NULL,
( ( i_opt || p_data->enqueue ) ? 0 : PLAYLIST_GO ),
PLAYLIST_END,
i_options,
(char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
VLC_INPUT_OPTION_TRUSTED,
......
......@@ -287,7 +287,7 @@
input_item_AddOption(p_input, [[NSString stringWithFormat:@"ttl=%@", [_streamTTLField stringValue]] UTF8String], VLC_INPUT_OPTION_TRUSTED);
int returnValue;
returnValue = playlist_AddInput(p_playlist, p_input, PLAYLIST_STOP, PLAYLIST_END, true );
returnValue = playlist_AddInput(p_playlist, p_input, PLAYLIST_STOP, true );
if (returnValue == VLC_SUCCESS) {
/* let's "play" */
......
......@@ -1445,7 +1445,7 @@ static bool HandleBrowseKey(intf_thread_t *intf, int key)
input_item_t *p_input = p_playlist->p_playing->p_input;
playlist_Add(p_playlist, uri, NULL, 0,
PLAYLIST_END, p_parent->p_input == p_input);
p_parent->p_input == p_input);
BoxSwitch(sys, BOX_PLAYLIST);
free(uri);
......@@ -1480,7 +1480,7 @@ static void OpenSelection(intf_thread_t *intf)
p_parent = p_parent->p_parent;
PL_UNLOCK;
playlist_Add(p_playlist, uri, NULL, PLAYLIST_GO, PLAYLIST_END,
playlist_Add(p_playlist, uri, NULL, PLAYLIST_GO,
p_parent->p_input == p_playlist->p_playing->p_input);
sys->plidx_follow = true;
......
......@@ -236,7 +236,6 @@ int Open::openMRLwithOptions( intf_thread_t* p_intf,
int i_ret = playlist_AddExt( THEPL,
qtu(mrl), title,
(b_start ? PLAYLIST_GO : 0),
PLAYLIST_END,
i_options, ppsz_options, VLC_INPUT_OPTION_TRUSTED,
b_playlist );
......
......@@ -44,6 +44,5 @@ void CmdAddItem::execute()
free( psz_uri );
}
playlist_Add( pPlaylist, m_name.c_str(), NULL,
m_playNow ? PLAYLIST_GO : 0,
PLAYLIST_END, true );
m_playNow ? PLAYLIST_GO : 0, true );
}
......@@ -579,7 +579,7 @@ int vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
/* FIXME: playlist_AddInput() can fail */
playlist_AddInput( p_playlist, p_input,
( b_play ? PLAYLIST_GO : 0 ),
PLAYLIST_END, true );
true );
i_count ++; /* increment counter */
vlc_gc_decref( p_input );
while( i_options > 0 )
......
......@@ -174,10 +174,14 @@ int intf_InsertItem(libvlc_int_t *libvlc, const char *mrl, unsigned optc,
int ret = -1;
if (input_item_AddOptions(item, optc, optv, flags) == VLC_SUCCESS
&& playlist_AddInput(playlist, item, 0, 0, true) == VLC_SUCCESS)
ret = 0;
if (input_item_AddOptions(item, optc, optv, flags) == VLC_SUCCESS)
{
playlist_Lock(playlist);
if (playlist_NodeAddInput(playlist, item, playlist->p_playing, 0,
0) != NULL)
ret = 0;
playlist_Unlock(playlist);
}
input_item_Release(item);
return ret;
}
......
......@@ -100,7 +100,7 @@ static void IPCHelperThread( void *arg )
playlist_AddExt( p_playlist, ppsz_argv[ i_opt ], NULL,
(( i_opt || ulCmd == IPC_CMD_ENQUEUE ) ?
0 : PLAYLIST_GO ),
PLAYLIST_END, i_options,
i_options,
( char const ** )
( i_options ? &ppsz_argv[ i_opt + 1 ] :
NULL ),
......
......@@ -448,18 +448,14 @@ void playlist_Clear( playlist_t * p_playlist, bool b_locked )
* \param psz_uri the mrl to add to the playlist
* \param psz_name a text giving a name or description of this item
* \param i_mode the mode used when adding
* \param i_pos the position in the playlist where to add. If this is
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of its size
* \param b_playlist TRUE for playlist, FALSE for media library
* \return VLC_SUCCESS or a VLC error code
*/
int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
const char *psz_name, int i_mode, int i_pos,
bool b_playlist )
const char *psz_name, int i_mode, bool b_playlist )
{
return playlist_AddExt( p_playlist, psz_uri, psz_name,
i_mode, i_pos, 0, NULL, 0, b_playlist );
i_mode, 0, NULL, 0, b_playlist );
}
/**
......@@ -469,9 +465,6 @@ int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
* \param psz_uri the mrl to add to the playlist
* \param psz_name a text giving a name or description of this item
* \param i_mode the mode used when adding
* \param i_pos the position in the playlist where to add. If this is
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of its size
* \param i_options the number of options
* \param ppsz_options an array of options
* \param i_option_flags options flags
......@@ -479,7 +472,7 @@ int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
* \return VLC_SUCCESS or a VLC error code
*/
int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
const char *psz_name, int i_mode, int i_pos,
const char *psz_name, int i_mode,
int i_options, const char *const *ppsz_options,
unsigned i_option_flags,
bool b_playlist )
......@@ -491,8 +484,7 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
if( p_input == NULL )
return VLC_ENOMEM;
input_item_AddOptions( p_input, i_options, ppsz_options, i_option_flags );
i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos,
b_playlist );
i_ret = playlist_AddInput( p_playlist, p_input, i_mode, b_playlist );
vlc_gc_decref( p_input );
return i_ret;
}
......@@ -503,14 +495,11 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
* \param p_playlist the playlist to add into
* \param p_input the input item to add
* \param i_mode the mode used when adding
* \param i_pos the position in the playlist where to add. If this is
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of its size
* \param b_playlist TRUE for playlist, FALSE for media library
* \return VLC_SUCCESS or VLC_ENOMEM or VLC_EGENERIC
*/
int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
int i_mode, int i_pos, bool b_playlist )
int i_mode, bool b_playlist )
{
playlist_item_t *item;
......@@ -518,7 +507,8 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
item = b_playlist ? p_playlist->p_playing
: p_playlist->p_media_library;
item = playlist_NodeAddInput( p_playlist, p_input, item, i_mode, i_pos );
item = playlist_NodeAddInput( p_playlist, p_input, item, i_mode,
PLAYLIST_END );
PL_UNLOCK;
return (item != NULL) ? VLC_SUCCESS : VLC_ENOMEM;
}
......
......@@ -99,7 +99,7 @@ int playlist_Import( playlist_t *p_playlist, const char *psz_file )
p_input = input_item_New( psz_uri, psz_file );
free( psz_uri );
playlist_AddInput( p_playlist, p_input, 0, PLAYLIST_END, true );
playlist_AddInput( p_playlist, p_input, 0, true );
vlc_object_t *dummy = vlc_object_create( p_playlist, sizeof (*dummy) );
var_Create( dummy, "meta-file", VLC_VAR_VOID );
......
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