Merge pull request #188 from chme/playerfixes

Playerfixes
This commit is contained in:
ejurgensen 2015-10-19 22:15:43 +02:00
commit 9853b8f9bd
2 changed files with 19 additions and 8 deletions

View File

@ -1150,7 +1150,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
const char *shuffle; const char *shuffle;
uint32_t plid; uint32_t plid;
uint32_t id; uint32_t id;
uint32_t pos; int pos;
int ret; int ret;
/* /ctrl-int/1/playspec?database-spec='dmap.persistentid:0x1'&container-spec='dmap.persistentid:0x5'&container-item-spec='dmap.containeritemid:0x9' /* /ctrl-int/1/playspec?database-spec='dmap.persistentid:0x1'&container-spec='dmap.persistentid:0x5'&container-item-spec='dmap.containeritemid:0x9'
@ -1213,7 +1213,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
} }
param++; param++;
ret = safe_hextou32(param, &pos); ret = safe_hextou32(param, &id);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Couldn't convert container-item-spec/item-spec to an integer in playspec (%s)\n", param); DPRINTF(E_LOG, L_DACP, "Couldn't convert container-item-spec/item-spec to an integer in playspec (%s)\n", param);
@ -1222,15 +1222,15 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
} }
} }
else else
pos = 0; id = 0;
DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d%s\n", plid, pos, (shuffle) ? ", shuffle" : ""); DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d%s\n", plid, id, (shuffle) ? ", shuffle" : "");
items = NULL; items = NULL;
if (plid > 0) if (plid > 0)
items = queueitem_make_byplid(plid); items = queueitem_make_byplid(plid);
else if (pos > 0) else if (id > 0)
items = queueitem_make_byid(pos); items = queueitem_make_byid(id);
if (!items) if (!items)
{ {
@ -1239,6 +1239,12 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
goto out_fail; goto out_fail;
} }
pos = queueitem_pos(items, id);
if (pos < 0)
{
DPRINTF(E_DBG, L_DACP, "No item with %d found in queue\n", id);
pos = 0;
}
DPRINTF(E_DBG, L_DACP, "Playspec start song index is %d\n", pos); DPRINTF(E_DBG, L_DACP, "Playspec start song index is %d\n", pos);
player_get_status(&status); player_get_status(&status);
@ -1253,7 +1259,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
if (shuffle) if (shuffle)
dacp_propset_shufflestate(shuffle, NULL); dacp_propset_shufflestate(shuffle, NULL);
ret = player_playback_start_bypos(pos, &id); ret = player_playback_start_bypos(pos, NULL);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Could not start playback\n"); DPRINTF(E_LOG, L_DACP, "Could not start playback\n");

View File

@ -1507,7 +1507,7 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
{ {
ret = stream_read(cur_streaming, len - nbytes); ret = stream_read(cur_streaming, len - nbytes);
} }
else else if (cur_playing)
{ {
// Reached end of playlist (cur_playing is NULL) send silence and source_check will abort playback if the last item was played // Reached end of playlist (cur_playing is NULL) send silence and source_check will abort playback if the last item was played
DPRINTF(E_SPAM, L_PLAYER, "End of playlist reached, stream silence until playback of last item ends\n"); DPRINTF(E_SPAM, L_PLAYER, "End of playlist reached, stream silence until playback of last item ends\n");
@ -1516,6 +1516,11 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
free(silence_buf); free(silence_buf);
ret = len - nbytes; ret = len - nbytes;
} }
else
{
// If cur_streaming and cur_playing are NULL, source_read for all queue items failed. Playback will be aborted in the calling function
return -1;
}
if (ret <= 0) if (ret <= 0)
{ {