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 /src/playlist_queue.c | |
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/playlist_queue.c | 16 |
1 files changed, 14 insertions, 2 deletions
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) |