From 0103219f00bde7e5177c4bea4a2b9d21a61841ca Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Feb 2012 23:44:33 +0100 Subject: playlist_queue: add start/end_index parameters --- src/playlist_queue.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/playlist_queue.c') 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) -- cgit v1.2.3