Add support for shuffle in DACP playspec request

This commit is contained in:
Julien BLACHE 2010-07-31 12:07:51 +02:00
parent fa0ee0553a
commit 94b4cd2459
2 changed files with 39 additions and 23 deletions

View File

@ -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,6 +861,8 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
goto out_fail;
}
if (!shuffle)
{
/* Start song ID */
param = evhttp_find_header(query, "container-item-spec");
if (!param)
@ -882,8 +888,11 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
goto out_fail;
}
}
else
id = 0;
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)
{

View File

@ -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