command: playlistinfo now uses a range argument rather than just a song id
Loosely based on a patch provided by lesion in bug #1766. The playlistinfo command can now retrieve ranges of the playlist. The new argument indicates which entry is the last one that will be displayed. The number of displayed entries may be smaller than expected if the end of the playlist is reached. Previous usage: playlistinfo [start] New usage: playlistinfo [start[:end]]
This commit is contained in:

committed by
Max Kellermann

parent
8ed3cf3e6b
commit
6f0781f039
@@ -413,7 +413,7 @@ int playlistChangesPosId(struct client *client, uint32_t version)
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum playlist_result playlistInfo(struct client *client, int song)
|
||||
enum playlist_result playlistInfo(struct client *client, int song, int max)
|
||||
{
|
||||
unsigned begin = 0;
|
||||
unsigned end = playlist.length;
|
||||
@@ -424,6 +424,11 @@ enum playlist_result playlistInfo(struct client *client, int song)
|
||||
}
|
||||
if (song >= (int)playlist.length)
|
||||
return PLAYLIST_RESULT_BAD_RANGE;
|
||||
if (max > 0) {
|
||||
end = MIN((unsigned)(max + 1), playlist.length);
|
||||
if (end <= begin)
|
||||
return PLAYLIST_RESULT_BAD_RANGE;
|
||||
}
|
||||
|
||||
for (unsigned i = begin; i < end; i++)
|
||||
printPlaylistSongInfo(client, i);
|
||||
|
Reference in New Issue
Block a user