Commit 0103219f authored by Max Kellermann's avatar Max Kellermann

playlist_queue: add start/end_index parameters

parent e15b4f40
...@@ -800,7 +800,9 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) ...@@ -800,7 +800,9 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{ {
enum playlist_result result; 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); client->player_control, true);
if (result != PLAYLIST_RESULT_NO_SUCH_LIST) if (result != PLAYLIST_RESULT_NO_SUCH_LIST)
return print_playlist_result(client, result); return print_playlist_result(client, result);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
enum playlist_result enum playlist_result
playlist_load_into_queue(const char *uri, struct playlist_provider *source, playlist_load_into_queue(const char *uri, struct playlist_provider *source,
unsigned start_index, unsigned end_index,
struct playlist *dest, struct player_control *pc, struct playlist *dest, struct player_control *pc,
bool secure) bool secure)
{ {
...@@ -35,7 +36,16 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, ...@@ -35,7 +36,16 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source,
struct song *song; struct song *song;
char *base_uri = uri != NULL ? g_path_get_dirname(uri) : NULL; 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); song = playlist_check_translate_song(song, base_uri, secure);
if (song == NULL) if (song == NULL)
continue; continue;
...@@ -56,6 +66,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, ...@@ -56,6 +66,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source,
enum playlist_result enum playlist_result
playlist_open_into_queue(const char *uri, playlist_open_into_queue(const char *uri,
unsigned start_index, unsigned end_index,
struct playlist *dest, struct player_control *pc, struct playlist *dest, struct player_control *pc,
bool secure) bool secure)
{ {
...@@ -72,7 +83,8 @@ playlist_open_into_queue(const char *uri, ...@@ -72,7 +83,8 @@ playlist_open_into_queue(const char *uri,
} }
enum playlist_result result = 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); playlist_plugin_close(playlist);
if (is != NULL) if (is != NULL)
......
...@@ -38,9 +38,12 @@ struct player_control; ...@@ -38,9 +38,12 @@ struct player_control;
* *
* @param uri the URI of the playlist, used to resolve relative song * @param uri the URI of the playlist, used to resolve relative song
* URIs * URIs
* @param start_index the index of the first song
* @param end_index the index of the last song (excluding)
*/ */
enum playlist_result enum playlist_result
playlist_load_into_queue(const char *uri, struct playlist_provider *source, playlist_load_into_queue(const char *uri, struct playlist_provider *source,
unsigned start_index, unsigned end_index,
struct playlist *dest, struct player_control *pc, struct playlist *dest, struct player_control *pc,
bool secure); bool secure);
...@@ -50,6 +53,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source, ...@@ -50,6 +53,7 @@ playlist_load_into_queue(const char *uri, struct playlist_provider *source,
*/ */
enum playlist_result enum playlist_result
playlist_open_into_queue(const char *uri, playlist_open_into_queue(const char *uri,
unsigned start_index, unsigned end_index,
struct playlist *dest, struct player_control *pc, struct playlist *dest, struct player_control *pc,
bool secure); bool secure);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment