mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
Add support for shuffle in DACP playspec request
This commit is contained in:
parent
fa0ee0553a
commit
94b4cd2459
@ -819,6 +819,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
struct player_source *ps;
|
||||
struct daap_session *s;
|
||||
const char *param;
|
||||
const char *shuffle;
|
||||
uint32_t plid;
|
||||
uint32_t id;
|
||||
int ret;
|
||||
@ -831,6 +832,9 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
/* Check for shuffle */
|
||||
shuffle = evhttp_find_header(query, "dacp.shufflestate");
|
||||
|
||||
/* Playlist ID */
|
||||
param = evhttp_find_header(query, "container-spec");
|
||||
if (!param)
|
||||
@ -857,33 +861,38 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
/* Start song ID */
|
||||
param = evhttp_find_header(query, "container-item-spec");
|
||||
if (!param)
|
||||
if (!shuffle)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "No container-item-spec in playspec request\n");
|
||||
/* Start song ID */
|
||||
param = evhttp_find_header(query, "container-item-spec");
|
||||
if (!param)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "No container-item-spec in playspec request\n");
|
||||
|
||||
goto out_fail;
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
param = strchr(param, ':');
|
||||
if (!param)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "Malformed container-item-spec parameter in playspec request\n");
|
||||
|
||||
goto out_fail;
|
||||
}
|
||||
param++;
|
||||
|
||||
ret = safe_hextou32(param, &id);
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "Couldn't convert container-item-spec to an integer in playspec (%s)\n", param);
|
||||
|
||||
goto out_fail;
|
||||
}
|
||||
}
|
||||
else
|
||||
id = 0;
|
||||
|
||||
param = strchr(param, ':');
|
||||
if (!param)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "Malformed container-item-spec parameter in playspec request\n");
|
||||
|
||||
goto out_fail;
|
||||
}
|
||||
param++;
|
||||
|
||||
ret = safe_hextou32(param, &id);
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DACP, "Couldn't convert container-item-spec to an integer in playspec (%s)\n", param);
|
||||
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d\n", plid, id);
|
||||
DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d%s\n", plid, id, (shuffle) ? ", shuffle" : "");
|
||||
|
||||
ps = player_queue_make_pl(plid, &id);
|
||||
if (!ps)
|
||||
@ -903,6 +912,9 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
player_queue_clear();
|
||||
player_queue_add(ps);
|
||||
|
||||
if (shuffle)
|
||||
dacp_propset_shufflestate(shuffle, NULL);
|
||||
|
||||
ret = player_playback_start(&id);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -474,6 +474,10 @@ player_queue_make_pl(int plid, uint32_t *id)
|
||||
|
||||
ps = player_queue_make(&qp, NULL);
|
||||
|
||||
/* Shortcut for shuffled playlist */
|
||||
if (*id == 0)
|
||||
return ps;
|
||||
|
||||
p = ps;
|
||||
i = 0;
|
||||
do
|
||||
|
Loading…
Reference in New Issue
Block a user