diff options
author | Max Kellermann <max@duempel.org> | 2012-02-09 23:44:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-02-09 23:44:33 +0100 |
commit | 0103219f00bde7e5177c4bea4a2b9d21a61841ca (patch) | |
tree | c83afdb4fba840ed9aba93eb666172e563d395b2 | |
parent | e15b4f40d6d5d9691c6321036aee13ab9962684d (diff) | |
download | mpd-0103219f00bde7e5177c4bea4a2b9d21a61841ca.tar.gz mpd-0103219f00bde7e5177c4bea4a2b9d21a61841ca.tar.xz mpd-0103219f00bde7e5177c4bea4a2b9d21a61841ca.zip |
playlist_queue: add start/end_index parameters
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 4 | ||||
-rw-r--r-- | src/playlist_queue.c | 16 | ||||
-rw-r--r-- | src/playlist_queue.h | 4 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c index 9810049ea..568997cc7 100644 --- a/src/command.c +++ b/src/command.c @@ -800,7 +800,9 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { enum playlist_result result; - result = playlist_open_into_queue(argv[1], &g_playlist, + result = playlist_open_into_queue(argv[1], + 0, G_MAXUINT, + &g_playlist, client->player_control, true); if (result != PLAYLIST_RESULT_NO_SUCH_LIST) return print_playlist_result(client, result); diff --git a/src/playlist_queue.c b/src/playlist_queue.c index 33885ae21..aada94984 100644 --- a/src/playlist_queue.c +++ b/src/playlist_queue.c @@ -28,6 +28,7 @@ enum playlist_result playlist_load_into_queue(const char *uri, struct playlist_provider *source, + unsigned start_index, unsigned end_index, struct playlist *dest, struct player_control *pc, bool secure) { @@ -35,7 +36,16 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, struct song *song; char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL; - while ((song = playlist_plugin_read(source)) != NULL) { + for (unsigned i = 0; + i < end_index && (song = playlist_plugin_read(source)) != NULL; + ++i) { + if (i < start_index) { + /* skip songs before the start index */ + if (!song_in_database(song)) + song_free(song); + continue; + } + song = playlist_check_translate_song(song, base_uri, secure); if (song == NULL) continue; @@ -56,6 +66,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, enum playlist_result playlist_open_into_queue(const char *uri, + unsigned start_index, unsigned end_index, struct playlist *dest, struct player_control *pc, bool secure) { @@ -72,7 +83,8 @@ playlist_open_into_queue(const char *uri, } enum playlist_result result = - playlist_load_into_queue(uri, playlist, dest, pc, secure); + playlist_load_into_queue(uri, playlist, start_index, end_index, + dest, pc, secure); playlist_plugin_close(playlist); if (is != NULL) diff --git a/src/playlist_queue.h b/src/playlist_queue.h index 3ae63bc16..24a851aab 100644 --- a/src/playlist_queue.h +++ b/src/playlist_queue.h @@ -38,9 +38,12 @@ struct player_control; * * @param uri the URI of the playlist, used to resolve relative song * URIs + * @param start_index the index of the first song + * @param end_index the index of the last song (excluding) */ enum playlist_result playlist_load_into_queue(const char *uri, struct playlist_provider *source, + unsigned start_index, unsigned end_index, struct playlist *dest, struct player_control *pc, bool secure); @@ -50,6 +53,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, */ enum playlist_result playlist_open_into_queue(const char *uri, + unsigned start_index, unsigned end_index, struct playlist *dest, struct player_control *pc, bool secure); |