mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 04:57:06 +03:00
fix DMAP parsing and a few compiler warning - release
This commit is contained in:
@@ -46,11 +46,11 @@ typedef struct {
|
|||||||
} dmap_field;
|
} dmap_field;
|
||||||
|
|
||||||
static const dmap_field dmap_fields[] = {
|
static const dmap_field dmap_fields[] = {
|
||||||
|
#ifdef DMAP_FULL
|
||||||
{ "abal", DMAP_DICT, DMAP_STR, "daap.browsealbumlisting" },
|
{ "abal", DMAP_DICT, DMAP_STR, "daap.browsealbumlisting" },
|
||||||
{ "abar", DMAP_DICT, DMAP_STR, "daap.browseartistlisting" },
|
{ "abar", DMAP_DICT, DMAP_STR, "daap.browseartistlisting" },
|
||||||
{ "abcp", DMAP_DICT, DMAP_STR, "daap.browsecomposerlisting" },
|
{ "abcp", DMAP_DICT, DMAP_STR, "daap.browsecomposerlisting" },
|
||||||
{ "abgn", DMAP_DICT, DMAP_STR, "daap.browsegenrelisting" },
|
{ "abgn", DMAP_DICT, DMAP_STR, "daap.browsegenrelisting" },
|
||||||
#ifdef DMAP_FULL
|
|
||||||
{ "abpl", DMAP_UINT, 0, "daap.baseplaylist" },
|
{ "abpl", DMAP_UINT, 0, "daap.baseplaylist" },
|
||||||
{ "abro", DMAP_DICT, 0, "daap.databasebrowse" },
|
{ "abro", DMAP_DICT, 0, "daap.databasebrowse" },
|
||||||
{ "adbs", DMAP_DICT, 0, "daap.databasesongs" },
|
{ "adbs", DMAP_DICT, 0, "daap.databasesongs" },
|
||||||
@@ -139,8 +139,10 @@ static const dmap_field dmap_fields[] = {
|
|||||||
{ "asaa", DMAP_STR, 0, "daap.songalbumartist" },
|
{ "asaa", DMAP_STR, 0, "daap.songalbumartist" },
|
||||||
{ "asac", DMAP_UINT, 0, "daap.songartworkcount" },
|
{ "asac", DMAP_UINT, 0, "daap.songartworkcount" },
|
||||||
{ "asai", DMAP_UINT, 0, "daap.songalbumid" },
|
{ "asai", DMAP_UINT, 0, "daap.songalbumid" },
|
||||||
|
#endif
|
||||||
{ "asal", DMAP_STR, 0, "daap.songalbum" },
|
{ "asal", DMAP_STR, 0, "daap.songalbum" },
|
||||||
{ "asar", DMAP_STR, 0, "daap.songartist" },
|
{ "asar", DMAP_STR, 0, "daap.songartist" },
|
||||||
|
#ifdef DMAP_FULL
|
||||||
{ "asas", DMAP_UINT, 0, "daap.songalbumuserratingstatus" },
|
{ "asas", DMAP_UINT, 0, "daap.songalbumuserratingstatus" },
|
||||||
{ "asbk", DMAP_UINT, 0, "daap.bookmarkable" },
|
{ "asbk", DMAP_UINT, 0, "daap.bookmarkable" },
|
||||||
{ "asbo", DMAP_UINT, 0, "daap.songbookmark" },
|
{ "asbo", DMAP_UINT, 0, "daap.songbookmark" },
|
||||||
@@ -257,12 +259,12 @@ static const dmap_field dmap_fields[] = {
|
|||||||
{ "meia", DMAP_UINT, 0, "dmap.itemdateadded" },
|
{ "meia", DMAP_UINT, 0, "dmap.itemdateadded" },
|
||||||
{ "meip", DMAP_UINT, 0, "dmap.itemdateplayed" },
|
{ "meip", DMAP_UINT, 0, "dmap.itemdateplayed" },
|
||||||
{ "mext", DMAP_UINT, 0, "dmap.objectextradata" },
|
{ "mext", DMAP_UINT, 0, "dmap.objectextradata" },
|
||||||
#endif
|
|
||||||
{ "miid", DMAP_UINT, 0, "dmap.itemid" },
|
{ "miid", DMAP_UINT, 0, "dmap.itemid" },
|
||||||
{ "mikd", DMAP_UINT, 0, "dmap.itemkind" },
|
{ "mikd", DMAP_UINT, 0, "dmap.itemkind" },
|
||||||
{ "mimc", DMAP_UINT, 0, "dmap.itemcount" },
|
{ "mimc", DMAP_UINT, 0, "dmap.itemcount" },
|
||||||
|
#endif
|
||||||
{ "minm", DMAP_STR, 0, "dmap.itemname" },
|
{ "minm", DMAP_STR, 0, "dmap.itemname" },
|
||||||
#ifdef DMAP_FULL
|
#ifdef DMAP_FULL
|
||||||
{ "mlcl", DMAP_DICT, DMAP_DICT, "dmap.listing" },
|
{ "mlcl", DMAP_DICT, DMAP_DICT, "dmap.listing" },
|
||||||
{ "mlid", DMAP_UINT, 0, "dmap.sessionid" },
|
{ "mlid", DMAP_UINT, 0, "dmap.sessionid" },
|
||||||
{ "mlit", DMAP_ITEM, 0, "dmap.listingitem" },
|
{ "mlit", DMAP_ITEM, 0, "dmap.listingitem" },
|
||||||
@@ -317,7 +319,7 @@ static const dmap_field dmap_fields[] = {
|
|||||||
{ "prat", DMAP_UINT, 0, "dpap.imagerating" },
|
{ "prat", DMAP_UINT, 0, "dpap.imagerating" },
|
||||||
{ "pret", DMAP_DICT, 0, "dpap.retryids" },
|
{ "pret", DMAP_DICT, 0, "dpap.retryids" },
|
||||||
{ "pwth", DMAP_UINT, 0, "dpap.imagepixelwidth" }
|
{ "pwth", DMAP_UINT, 0, "dpap.imagepixelwidth" }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
static const size_t dmap_field_count = sizeof(dmap_fields) / sizeof(dmap_field);
|
static const size_t dmap_field_count = sizeof(dmap_fields) / sizeof(dmap_field);
|
||||||
|
|
||||||
@@ -424,7 +426,7 @@ static int dmap_parse_internal(const dmap_settings *settings, const char *buf, s
|
|||||||
/* Make a best guess of the type */
|
/* Make a best guess of the type */
|
||||||
field_type = DMAP_UNKNOWN;
|
field_type = DMAP_UNKNOWN;
|
||||||
field_name = code;
|
field_name = code;
|
||||||
#ifdef DMAP_FULL
|
|
||||||
if (field_len >= 8) {
|
if (field_len >= 8) {
|
||||||
/* Look for a four char code followed by a length within the current field */
|
/* Look for a four char code followed by a length within the current field */
|
||||||
if (isalpha(p[0] & 0xff) &&
|
if (isalpha(p[0] & 0xff) &&
|
||||||
@@ -435,7 +437,7 @@ static int dmap_parse_internal(const dmap_settings *settings, const char *buf, s
|
|||||||
field_type = DMAP_DICT;
|
field_type = DMAP_DICT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DMAP_FULL
|
||||||
if (field_type == DMAP_UNKNOWN) {
|
if (field_type == DMAP_UNKNOWN) {
|
||||||
size_t i;
|
size_t i;
|
||||||
int is_string = 1;
|
int is_string = 1;
|
||||||
@@ -448,7 +450,7 @@ static int dmap_parse_internal(const dmap_settings *settings, const char *buf, s
|
|||||||
|
|
||||||
field_type = is_string ? DMAP_STR : DMAP_UINT;
|
field_type = is_string ? DMAP_STR : DMAP_UINT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (field_type) {
|
switch (field_type) {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ struct raop_ctx_s *raop_create(uint32_t host, char *name,
|
|||||||
getsockname(ctx->sock, (struct sockaddr *) &addr, &nlen);
|
getsockname(ctx->sock, (struct sockaddr *) &addr, &nlen);
|
||||||
ctx->port = ntohs(addr.sin_port);
|
ctx->port = ntohs(addr.sin_port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ctx->running = true;
|
ctx->running = true;
|
||||||
|
|
||||||
memcpy(ctx->mac, mac, 6);
|
memcpy(ctx->mac, mac, 6);
|
||||||
@@ -193,7 +193,7 @@ struct raop_ctx_s *raop_create(uint32_t host, char *name,
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// seems that Windows snprintf does not add NULL char if actual size > max
|
// seems that Windows snprintf does not add NULL char if actual size > max
|
||||||
id[63] = '\0';
|
id[63] = '\0';
|
||||||
ctx->svc = mdnsd_register_svc(ctx->svr, id, "_raop._tcp.local", ctx->port, NULL, (const char**) txt);
|
ctx->svc = mdnsd_register_svc(ctx->svr, id, "_raop._tcp.local", ctx->port, NULL, (const char**) txt);
|
||||||
pthread_create(&ctx->thread, NULL, &rtsp_thread, ctx);
|
pthread_create(&ctx->thread, NULL, &rtsp_thread, ctx);
|
||||||
|
|
||||||
@@ -619,12 +619,12 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock)
|
|||||||
LOG_INFO("[%p]: SET PARAMETER progress %d/%u %s", ctx, current, stop, p);
|
LOG_INFO("[%p]: SET PARAMETER progress %d/%u %s", ctx, current, stop, p);
|
||||||
success = ctx->cmd_cb(RAOP_PROGRESS, max(current, 0), stop);
|
success = ctx->cmd_cb(RAOP_PROGRESS, max(current, 0), stop);
|
||||||
} else if (body && ((p = kd_lookup(headers, "Content-Type")) != NULL) && !strcasecmp(p, "application/x-dmap-tagged")) {
|
} else if (body && ((p = kd_lookup(headers, "Content-Type")) != NULL) && !strcasecmp(p, "application/x-dmap-tagged")) {
|
||||||
struct metadata_s metadata;
|
|
||||||
struct metadata_s metadata;
|
struct metadata_s metadata;
|
||||||
dmap_settings settings = {
|
dmap_settings settings = {
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, on_dmap_string, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, on_dmap_string, NULL,
|
||||||
NULL
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
settings.ctx = &metadata;
|
settings.ctx = &metadata;
|
||||||
memset(&metadata, 0, sizeof(struct metadata_s));
|
memset(&metadata, 0, sizeof(struct metadata_s));
|
||||||
if (!dmap_parse(&settings, body, len)) {
|
if (!dmap_parse(&settings, body, len)) {
|
||||||
@@ -873,7 +873,7 @@ static int base64_pad(char *src, char **padded)
|
|||||||
memset(*padded, '=', n);
|
memset(*padded, '=', n);
|
||||||
memcpy(*padded, src, strlen(src));
|
memcpy(*padded, src, strlen(src));
|
||||||
(*padded)[n] = '\0';
|
(*padded)[n] = '\0';
|
||||||
|
|
||||||
return strlen(*padded);
|
return strlen(*padded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,7 +959,7 @@ static int base64_decode(const char *str, void *data)
|
|||||||
*q++ = (val >> 8) & 0xff;
|
*q++ = (val >> 8) & 0xff;
|
||||||
if (marker < 1)
|
if (marker < 1)
|
||||||
*q++ = val & 0xff;
|
*q++ = val & 0xff;
|
||||||
}
|
}
|
||||||
return q - (unsigned char *) data;
|
return q - (unsigned char *) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user