aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PlaylistPrint.cxx12
-rw-r--r--src/PlaylistPrint.hxx6
-rw-r--r--src/command/AllCommands.cxx4
-rw-r--r--src/command/QueueCommands.cxx14
-rw-r--r--src/queue/QueuePrint.cxx27
-rw-r--r--src/queue/QueuePrint.hxx6
6 files changed, 52 insertions, 17 deletions
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index 80f348710..c8abd89be 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -104,17 +104,21 @@ playlist_print_find(Response &r, Partition &partition,
void
playlist_print_changes_info(Response &r, Partition &partition,
const playlist &playlist,
- uint32_t version)
+ uint32_t version,
+ unsigned start, unsigned end)
{
- queue_print_changes_info(r, partition, playlist.queue, version);
+ queue_print_changes_info(r, partition, playlist.queue, version,
+ start, end);
}
void
playlist_print_changes_position(Response &r,
const playlist &playlist,
- uint32_t version)
+ uint32_t version,
+ unsigned start, unsigned end)
{
- queue_print_changes_position(r, playlist.queue, version);
+ queue_print_changes_position(r, playlist.queue, version,
+ start, end);
}
#ifdef ENABLE_DATABASE
diff --git a/src/PlaylistPrint.hxx b/src/PlaylistPrint.hxx
index bc4c2cb47..b12162262 100644
--- a/src/PlaylistPrint.hxx
+++ b/src/PlaylistPrint.hxx
@@ -79,7 +79,8 @@ playlist_print_find(Response &r, Partition &partition,
void
playlist_print_changes_info(Response &r, Partition &partition,
const playlist &playlist,
- uint32_t version);
+ uint32_t version,
+ unsigned start, unsigned end);
/**
* Print changes since the specified playlist version, position only.
@@ -87,7 +88,8 @@ playlist_print_changes_info(Response &r, Partition &partition,
void
playlist_print_changes_position(Response &r,
const playlist &playlist,
- uint32_t version);
+ uint32_t version,
+ unsigned start, unsigned end);
/**
* Send the stored playlist to the client.
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx
index 8e8865ff3..87ed7a1dc 100644
--- a/src/command/AllCommands.cxx
+++ b/src/command/AllCommands.cxx
@@ -148,8 +148,8 @@ static constexpr struct command commands[] = {
{ "playlistinfo", PERMISSION_READ, 0, 1, handle_playlistinfo },
{ "playlistmove", PERMISSION_CONTROL, 3, 3, handle_playlistmove },
{ "playlistsearch", PERMISSION_READ, 2, -1, handle_playlistsearch },
- { "plchanges", PERMISSION_READ, 1, 1, handle_plchanges },
- { "plchangesposid", PERMISSION_READ, 1, 1, handle_plchangesposid },
+ { "plchanges", PERMISSION_READ, 1, 2, handle_plchanges },
+ { "plchangesposid", PERMISSION_READ, 1, 2, handle_plchangesposid },
{ "previous", PERMISSION_CONTROL, 0, 0, handle_previous },
{ "prio", PERMISSION_CONTROL, 2, -1, handle_prio },
{ "prioid", PERMISSION_CONTROL, 2, -1, handle_prioid },
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index 7751aa26d..141c5170a 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -251,8 +251,13 @@ handle_plchanges(Client &client, Request args, Response &r)
if (!ParseCommandArg32(r, version, args.front()))
return CommandResult::ERROR;
+ RangeArg range = RangeArg::All();
+ if (!args.ParseOptional(1, range, r))
+ return CommandResult::ERROR;
+
playlist_print_changes_info(r, client.partition,
- client.playlist, version);
+ client.playlist, version,
+ range.start, range.end);
return CommandResult::OK;
}
@@ -263,7 +268,12 @@ handle_plchangesposid(Client &client, Request args, Response &r)
if (!ParseCommandArg32(r, version, args.front()))
return CommandResult::ERROR;
- playlist_print_changes_position(r, client.playlist, version);
+ RangeArg range = RangeArg::All();
+ if (!args.ParseOptional(1, range, r))
+ return CommandResult::ERROR;
+
+ playlist_print_changes_position(r, client.playlist, version,
+ range.start, range.end);
return CommandResult::OK;
}
diff --git a/src/queue/QueuePrint.cxx b/src/queue/QueuePrint.cxx
index 5ae1a3036..a7298c81f 100644
--- a/src/queue/QueuePrint.cxx
+++ b/src/queue/QueuePrint.cxx
@@ -71,19 +71,36 @@ queue_print_uris(Response &r, Partition &partition, const Queue &queue,
void
queue_print_changes_info(Response &r, Partition &partition, const Queue &queue,
- uint32_t version)
+ uint32_t version,
+ unsigned start, unsigned end)
{
- for (unsigned i = 0; i < queue.GetLength(); i++) {
+ assert(start <= end);
+
+ if (start >= queue.GetLength())
+ return;
+
+ if (end > queue.GetLength())
+ end = queue.GetLength();
+
+ for (unsigned i = start; i < end; i++)
if (queue.IsNewerAtPosition(i, version))
queue_print_song_info(r, partition, queue, i);
- }
}
void
queue_print_changes_position(Response &r, const Queue &queue,
- uint32_t version)
+ uint32_t version,
+ unsigned start, unsigned end)
{
- for (unsigned i = 0; i < queue.GetLength(); i++)
+ assert(start <= end);
+
+ if (start >= queue.GetLength())
+ return;
+
+ if (end > queue.GetLength())
+ end = queue.GetLength();
+
+ for (unsigned i = start; i < end; i++)
if (queue.IsNewerAtPosition(i, version))
r.Format("cpos: %i\nId: %i\n",
i, queue.PositionToId(i));
diff --git a/src/queue/QueuePrint.hxx b/src/queue/QueuePrint.hxx
index 88d28e8ca..461987520 100644
--- a/src/queue/QueuePrint.hxx
+++ b/src/queue/QueuePrint.hxx
@@ -42,11 +42,13 @@ queue_print_uris(Response &r, Partition &partition, const Queue &queue,
void
queue_print_changes_info(Response &r, Partition &partition, const Queue &queue,
- uint32_t version);
+ uint32_t version,
+ unsigned start, unsigned end);
void
queue_print_changes_position(Response &r, const Queue &queue,
- uint32_t version);
+ uint32_t version,
+ unsigned start, unsigned end);
void
queue_find(Response &response, Partition &partition, const Queue &queue,