medialibrary: playlist: allow removing a range of media

This commit is contained in:
Alaric Senat 2024-09-26 15:11:08 +02:00 committed by Steve Lhomme
parent 31e76890f8
commit 8b78a74aa2
3 changed files with 6 additions and 5 deletions

View File

@ -628,10 +628,10 @@ enum vlc_ml_control
/* Playlist management */
VLC_ML_PLAYLIST_CREATE, /**< arg1: const char*; arg2(out): vlc_ml_playlist_t**; can fail */
VLC_ML_PLAYLIST_DELETE, /**< arg1: playlist id; can fail */
VLC_ML_PLAYLIST_REMOVE, /**< arg1: playlist id; arg2: position; can fail */
VLC_ML_PLAYLIST_APPEND, /**< arg1: playlist id; arg2: pointer on media ids; arg3: media ids count; can fail */
VLC_ML_PLAYLIST_INSERT, /**< arg1: playlist id; arg2: pointer on media ids; arg3: media ids count; arg4: position; can fail */
VLC_ML_PLAYLIST_MOVE, /**< arg1: playlist id; arg2: from; arg3: to; arg4: count; can fail */
VLC_ML_PLAYLIST_REMOVE, /**< arg1: playlist id; arg2: position; arg3: count; can fail */
VLC_ML_PLAYLIST_RENAME, /**< arg1: playlist id; arg2: const char*; can fail */
/* Set Favorites */
@ -1249,11 +1249,11 @@ vlc_ml_playlist_move( vlc_medialibrary_t * p_ml,
}
static inline int
vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32_t i_position )
vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32_t i_position, uint32_t i_count )
{
assert( p_ml != NULL );
return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position );
return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position, i_count );
}
static inline int

View File

@ -238,7 +238,7 @@ void MLPlaylistModel::removeImpl(int64_t playlistId, const std::vector<std::pair
[playlistId, range](vlc_medialibrary_t* ml) {
for (int i = range.second; i >= range.first; i--)
{
vlc_ml_playlist_remove(ml, playlistId, i);
vlc_ml_playlist_remove(ml, playlistId, i, 1);
}
},
//UI thread

View File

@ -767,7 +767,8 @@ int MediaLibrary::Control( int query, va_list args )
if ( playlist == nullptr )
return VLC_EGENERIC;
uint32_t position = va_arg( args, uint32_t );
if ( playlist->remove(position) == false )
uint32_t count = va_arg( args, uint32_t );
if ( playlist->remove(position, count) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}