vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sat Nov 19 13:26:21 2016 +0200| [b459e18dbfbe462313fc46d99b3a6a81e69a4d32] | committer: 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. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b459e18dbfbe462313fc46d99b3a6a81e69a4d32 --- include/vlc_playlist.h | 6 +++--- modules/control/dbus/dbus_player.c | 2 +- modules/control/oldrc.c | 4 ++-- modules/control/win_msg.c | 1 - .../gui/macosx/VLCConvertAndSaveWindowController.m | 2 +- modules/gui/ncurses.c | 4 ++-- modules/gui/qt/recents.cpp | 1 - modules/gui/skins2/commands/cmd_add_item.cpp | 3 +-- modules/lua/vlc.c | 2 +- src/interface/interface.c | 12 +++++++---- src/os2/specific.c | 2 +- src/playlist/item.c | 24 +++++++--------------- src/playlist/loadsave.c | 2 +- 13 files changed, 28 insertions(+), 37 deletions(-) diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index 2ea0811..5fef490 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -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 ); diff --git a/modules/control/dbus/dbus_player.c b/modules/control/dbus/dbus_player.c index dc7b37b..04aab4e 100644 --- a/modules/control/dbus/dbus_player.c +++ b/modules/control/dbus/dbus_player.c @@ -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; } diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c index 828444f..bf695e5 100644 --- a/modules/control/oldrc.c +++ b/modules/control/oldrc.c @@ -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; } diff --git a/modules/control/win_msg.c b/modules/control/win_msg.c index 6b1dd52..12011a8 100644 --- a/modules/control/win_msg.c +++ b/modules/control/win_msg.c @@ -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, diff --git a/modules/gui/macosx/VLCConvertAndSaveWindowController.m b/modules/gui/macosx/VLCConvertAndSaveWindowController.m index a77d479..088e2c3 100644 --- a/modules/gui/macosx/VLCConvertAndSaveWindowController.m +++ b/modules/gui/macosx/VLCConvertAndSaveWindowController.m @@ -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" */ diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c index 8c239a4..f429798 100644 --- a/modules/gui/ncurses.c +++ b/modules/gui/ncurses.c @@ -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; diff --git a/modules/gui/qt/recents.cpp b/modules/gui/qt/recents.cpp index 82dff23..cfb3d1a 100644 --- a/modules/gui/qt/recents.cpp +++ b/modules/gui/qt/recents.cpp @@ -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 ); diff --git a/modules/gui/skins2/commands/cmd_add_item.cpp b/modules/gui/skins2/commands/cmd_add_item.cpp index 24e89c1..b39e10c 100644 --- a/modules/gui/skins2/commands/cmd_add_item.cpp +++ b/modules/gui/skins2/commands/cmd_add_item.cpp @@ -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 ); } diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c index 5166941..36d92e1 100644 --- a/modules/lua/vlc.c +++ b/modules/lua/vlc.c @@ -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 ) diff --git a/src/interface/interface.c b/src/interface/interface.c index 568215f..6306c04 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -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; } diff --git a/src/os2/specific.c b/src/os2/specific.c index 530211b..743c433 100644 --- a/src/os2/specific.c +++ b/src/os2/specific.c @@ -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 ), diff --git a/src/playlist/item.c b/src/playlist/item.c index a956f93..4fed025 100644 --- a/src/playlist/item.c +++ b/src/playlist/item.c @@ -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; } diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c index c9a5dbc..a3bb89d 100644 --- a/src/playlist/loadsave.c +++ b/src/playlist/loadsave.c @@ -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 ); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
