[dacp] Fix issue where Hyperfine Remote provides speaker ids as decimal

Also align a bit on how we handle hex/dec parameters
This commit is contained in:
ejurgensen 2017-08-27 00:02:39 +02:00
parent 8c0be3a0f3
commit c45a85d143
2 changed files with 22 additions and 8 deletions

View File

@ -716,7 +716,12 @@ dacp_propset_userrating(const char *value, struct evkeyvalq *query)
} }
param++; param++;
if (strncmp(param, "0x", 2) == 0)
ret = safe_hextou32(param, &itemid); ret = safe_hextou32(param, &itemid);
else
ret = safe_atou32(param, &itemid);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Couldn't convert item-spec/song-spec to an integer in dacp.userrating (%s)\n", param); DPRINTF(E_LOG, L_DACP, "Couldn't convert item-spec/song-spec to an integer in dacp.userrating (%s)\n", param);
@ -1224,7 +1229,11 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
} }
param++; param++;
if (strncmp(param, "0x", 2) == 0)
ret = safe_hextou32(param, &plid); ret = safe_hextou32(param, &plid);
else
ret = safe_atou32(param, &plid);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Couldn't convert container-spec to an integer in playspec (%s)\n", param); DPRINTF(E_LOG, L_DACP, "Couldn't convert container-spec to an integer in playspec (%s)\n", param);
@ -1253,7 +1262,11 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
} }
param++; param++;
if (strncmp(param, "0x", 2) == 0)
ret = safe_hextou32(param, &id); ret = safe_hextou32(param, &id);
else
ret = safe_atou32(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);
@ -2490,7 +2503,12 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
{ {
param++; param++;
// Some like Remote will give us hex, others will give us decimal (e.g. Hyperfine)
if (strncmp(param, "0x", 2) == 0)
ret = safe_hextou64(param, &ids[i]); ret = safe_hextou64(param, &ids[i]);
else
ret = safe_atou64(param, &ids[i]);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_DACP, "Invalid speaker id in request: %s\n", param); DPRINTF(E_LOG, L_DACP, "Invalid speaker id in request: %s\n", param);

View File

@ -130,10 +130,6 @@ safe_hextou32(const char *str, uint32_t *val)
*val = 0; *val = 0;
/* A hex shall begin with 0x */
if (strncmp(str, "0x", 2) != 0)
return safe_atou32(str, val);
errno = 0; errno = 0;
intval = strtoul(str, &end, 16); intval = strtoul(str, &end, 16);