medialibrary: Add the 'vlc_ml_playlist_rename' function

This commit is contained in:
Benjamin Arnaud 2023-05-16 11:34:59 +02:00 committed by Steve Lhomme
parent 62587d48fe
commit 6ffca1a9d3
2 changed files with 22 additions and 1 deletions

View File

@ -600,7 +600,8 @@ enum vlc_ml_control
VLC_ML_PLAYLIST_APPEND, /**< arg1: playlist id; arg2: media id; can fail */
VLC_ML_PLAYLIST_INSERT, /**< arg1: playlist id; arg2: media id; arg3: position; can fail */
VLC_ML_PLAYLIST_MOVE, /**< arg1: playlist id; arg2: from; arg3: to; can fail */
VLC_ML_PLAYLIST_REMOVE /**< arg1: playlist id; arg2: position; can fail */
VLC_ML_PLAYLIST_REMOVE, /**< arg1: playlist id; arg2: position; can fail */
VLC_ML_PLAYLIST_RENAME /**< arg1: playlist id; arg2: const char*; can fail */
};
/**
@ -1200,6 +1201,14 @@ vlc_ml_playlist_remove( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, uint32
return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_REMOVE, i_playlist_id, i_position );
}
static inline int
vlc_ml_playlist_rename( vlc_medialibrary_t * p_ml, int64_t i_playlist_id, const char* name )
{
assert( p_ml != NULL );
return vlc_ml_control( p_ml, VLC_ML_PLAYLIST_RENAME, i_playlist_id, name );
}
static inline vlc_ml_media_t* vlc_ml_get_media( vlc_medialibrary_t* p_ml, int64_t i_media_id )
{
return (vlc_ml_media_t*)vlc_ml_get( p_ml, VLC_ML_GET_MEDIA, i_media_id );

View File

@ -722,6 +722,18 @@ int MediaLibrary::Control( int query, va_list args )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
case VLC_ML_PLAYLIST_RENAME:
{
auto priorityAccess = m_ml->acquirePriorityAccess();
auto playlist = m_ml->playlist( va_arg( args, int64_t ) );
if ( playlist == nullptr )
return VLC_EGENERIC;
const char * name = va_arg( args, const char * );
if ( playlist->setName(name) == false )
return VLC_EGENERIC;
return VLC_SUCCESS;
}
default:
return VLC_EGENERIC;
}