command/QueueCommands: move code to RequireCurrentPosition()
This commit is contained in:
@@ -43,6 +43,17 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
RequireCurrentPosition(const playlist &p)
|
||||||
|
{
|
||||||
|
int position = p.GetCurrentPosition();
|
||||||
|
if (position < 0)
|
||||||
|
throw ProtocolError(ACK_ERROR_PLAYER_SYNC,
|
||||||
|
"No current song");
|
||||||
|
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
AddUri(Client &client, const LocatedUri &uri)
|
AddUri(Client &client, const LocatedUri &uri)
|
||||||
{
|
{
|
||||||
@@ -123,13 +134,9 @@ handle_addid(Client &client, Request args, Response &r)
|
|||||||
if (*s == '+') {
|
if (*s == '+') {
|
||||||
/* after the current song */
|
/* after the current song */
|
||||||
|
|
||||||
const int current =
|
const unsigned current =
|
||||||
partition.playlist.GetCurrentPosition();
|
RequireCurrentPosition(partition.playlist);
|
||||||
if (current < 0)
|
assert(current < queue_length);
|
||||||
throw ProtocolError(ACK_ERROR_PLAYER_SYNC,
|
|
||||||
"No current song");
|
|
||||||
|
|
||||||
assert(unsigned(current) < queue_length);
|
|
||||||
|
|
||||||
to = current + 1 +
|
to = current + 1 +
|
||||||
ParseCommandArgUnsigned(s + 1,
|
ParseCommandArgUnsigned(s + 1,
|
||||||
@@ -137,13 +144,9 @@ handle_addid(Client &client, Request args, Response &r)
|
|||||||
} else if (*s == '-') {
|
} else if (*s == '-') {
|
||||||
/* before the current song */
|
/* before the current song */
|
||||||
|
|
||||||
const int current =
|
const unsigned current =
|
||||||
partition.playlist.GetCurrentPosition();
|
RequireCurrentPosition(partition.playlist);
|
||||||
if (current < 0)
|
assert(current < queue_length);
|
||||||
throw ProtocolError(ACK_ERROR_PLAYER_SYNC,
|
|
||||||
"No current song");
|
|
||||||
|
|
||||||
assert(unsigned(current) < queue_length);
|
|
||||||
|
|
||||||
to = current - ParseCommandArgUnsigned(s + 1, current);
|
to = current - ParseCommandArgUnsigned(s + 1, current);
|
||||||
} else
|
} else
|
||||||
|
Reference in New Issue
Block a user