[httpd_dacp] Fix bug where not always increasing revision number (issue #423)

The bug affected Hyperfine Remote, which would not call back with a playstatusupdate
when it got a cmsr which had the same value as the previous (a value of 2)
This commit is contained in:
ejurgensen 2017-10-20 22:28:31 +02:00
parent a94fda38cc
commit 190e37e537

View File

@ -145,7 +145,8 @@ static int update_efd;
static int update_pipe[2]; static int update_pipe[2];
#endif #endif
static struct event *updateev; static struct event *updateev;
static int current_rev; /* Next revision number the client should call with */
static int next_rev;
/* Play status update requests */ /* Play status update requests */
static struct dacp_update_request *update_requests; static struct dacp_update_request *update_requests;
@ -265,7 +266,8 @@ make_playstatusupdate(struct evbuffer *evbuf)
dmap_add_int(psu, "mstt", 200); /* 12 */ dmap_add_int(psu, "mstt", 200); /* 12 */
dmap_add_int(psu, "cmsr", current_rev); /* 12 */ next_rev++;
dmap_add_int(psu, "cmsr", next_rev); /* 12 */
dmap_add_char(psu, "caps", status.status); /* 9 */ /* play status, 2 = stopped, 3 = paused, 4 = playing */ dmap_add_char(psu, "caps", status.status); /* 9 */ /* play status, 2 = stopped, 3 = paused, 4 = playing */
dmap_add_char(psu, "cash", status.shuffle); /* 9 */ /* shuffle, true/false */ dmap_add_char(psu, "cash", status.shuffle); /* 9 */ /* shuffle, true/false */
@ -383,8 +385,6 @@ playstatusupdate_cb(int fd, short what, void *arg)
free(ur); free(ur);
} }
current_rev++;
out_free_update: out_free_update:
evbuffer_free(update); evbuffer_free(update);
out_free_evbuf: out_free_evbuf:
@ -2116,8 +2116,10 @@ dacp_reply_playstatusupdate(struct evhttp_request *req, struct evbuffer *evbuf,
return; return;
} }
DPRINTF(E_LOG, L_DACP, "MARK Hanging on rev num %d...\n", reqd_rev);
/* Else, just let the request hang until we have changes to push back */ /* Else, just let the request hang until we have changes to push back */
ur = (struct dacp_update_request *)malloc(sizeof(struct dacp_update_request)); ur = calloc(1, sizeof(struct dacp_update_request));
if (!ur) if (!ur)
{ {
DPRINTF(E_LOG, L_DACP, "Out of memory for update request\n"); DPRINTF(E_LOG, L_DACP, "Out of memory for update request\n");
@ -2475,7 +2477,7 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
while ((ptr = strchr(ptr + 1, ','))) while ((ptr = strchr(ptr + 1, ',')))
nspk++; nspk++;
ids = (uint64_t *)malloc((nspk + 1) * sizeof(uint64_t)); ids = calloc((nspk + 1), sizeof(uint64_t));
if (!ids) if (!ids)
{ {
DPRINTF(E_LOG, L_DACP, "Out of memory for speaker ids\n"); DPRINTF(E_LOG, L_DACP, "Out of memory for speaker ids\n");
@ -2750,7 +2752,7 @@ dacp_init(void)
int i; int i;
int ret; int ret;
current_rev = 2; next_rev = 1;
update_requests = NULL; update_requests = NULL;
#ifdef HAVE_EVENTFD #ifdef HAVE_EVENTFD