diff --git a/components/raop/dmap_parser.c b/components/raop/dmap_parser.c index 67e43e8b..b013ad1d 100644 --- a/components/raop/dmap_parser.c +++ b/components/raop/dmap_parser.c @@ -46,11 +46,11 @@ typedef struct { } dmap_field; static const dmap_field dmap_fields[] = { +#ifdef DMAP_FULL { "abal", DMAP_DICT, DMAP_STR, "daap.browsealbumlisting" }, { "abar", DMAP_DICT, DMAP_STR, "daap.browseartistlisting" }, { "abcp", DMAP_DICT, DMAP_STR, "daap.browsecomposerlisting" }, { "abgn", DMAP_DICT, DMAP_STR, "daap.browsegenrelisting" }, -#ifdef DMAP_FULL { "abpl", DMAP_UINT, 0, "daap.baseplaylist" }, { "abro", DMAP_DICT, 0, "daap.databasebrowse" }, { "adbs", DMAP_DICT, 0, "daap.databasesongs" }, @@ -139,8 +139,10 @@ static const dmap_field dmap_fields[] = { { "asaa", DMAP_STR, 0, "daap.songalbumartist" }, { "asac", DMAP_UINT, 0, "daap.songartworkcount" }, { "asai", DMAP_UINT, 0, "daap.songalbumid" }, +#endif { "asal", DMAP_STR, 0, "daap.songalbum" }, { "asar", DMAP_STR, 0, "daap.songartist" }, +#ifdef DMAP_FULL { "asas", DMAP_UINT, 0, "daap.songalbumuserratingstatus" }, { "asbk", DMAP_UINT, 0, "daap.bookmarkable" }, { "asbo", DMAP_UINT, 0, "daap.songbookmark" }, @@ -257,12 +259,12 @@ static const dmap_field dmap_fields[] = { { "meia", DMAP_UINT, 0, "dmap.itemdateadded" }, { "meip", DMAP_UINT, 0, "dmap.itemdateplayed" }, { "mext", DMAP_UINT, 0, "dmap.objectextradata" }, -#endif { "miid", DMAP_UINT, 0, "dmap.itemid" }, { "mikd", DMAP_UINT, 0, "dmap.itemkind" }, { "mimc", DMAP_UINT, 0, "dmap.itemcount" }, +#endif { "minm", DMAP_STR, 0, "dmap.itemname" }, -#ifdef DMAP_FULL +#ifdef DMAP_FULL { "mlcl", DMAP_DICT, DMAP_DICT, "dmap.listing" }, { "mlid", DMAP_UINT, 0, "dmap.sessionid" }, { "mlit", DMAP_ITEM, 0, "dmap.listingitem" }, @@ -317,7 +319,7 @@ static const dmap_field dmap_fields[] = { { "prat", DMAP_UINT, 0, "dpap.imagerating" }, { "pret", DMAP_DICT, 0, "dpap.retryids" }, { "pwth", DMAP_UINT, 0, "dpap.imagepixelwidth" } -#endif +#endif }; 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 */ field_type = DMAP_UNKNOWN; field_name = code; -#ifdef DMAP_FULL + if (field_len >= 8) { /* Look for a four char code followed by a length within the current field */ 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; } } - +#ifdef DMAP_FULL if (field_type == DMAP_UNKNOWN) { size_t i; 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; } -#endif +#endif } switch (field_type) { diff --git a/components/raop/raop.c b/components/raop/raop.c index 827c43c1..22c658d7 100644 --- a/components/raop/raop.c +++ b/components/raop/raop.c @@ -185,7 +185,7 @@ struct raop_ctx_s *raop_create(uint32_t host, char *name, #endif ctx->running = true; memcpy(ctx->mac, mac, 6); - snprintf(id, 64, "%02X%02X%02X%02X%02X%02X@%s", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], name); + snprintf(id, 64, "%02X%02X%02X%02X%02X%02X@%s", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], name); #ifdef WIN32 // seems that Windows snprintf does not add NULL char if actual size > max id[63] = '\0'; @@ -193,7 +193,7 @@ struct raop_ctx_s *raop_create(uint32_t host, char *name, pthread_create(&ctx->thread, NULL, &rtsp_thread, ctx); #else LOG_INFO("starting mDNS with %s", id); - ESP_ERROR_CHECK( mdns_service_add(id, "_raop", "_tcp", ctx->port, txt, sizeof(txt) / sizeof(mdns_txt_item_t)) ); + mdns_service_add(id, "_raop", "_tcp", ctx->port, (mdns_txt_item_t*) txt, sizeof(txt) / sizeof(mdns_txt_item_t)); ctx->xTaskBuffer = (StaticTask_t*) heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); ctx->thread = xTaskCreateStaticPinnedToCore( (TaskFunction_t) rtsp_thread, "RTSP", RTSP_STACK_SIZE, ctx, @@ -619,12 +619,12 @@ static bool handle_rtsp(raop_ctx_t *ctx, int sock) NULL }; - LOG_INFO("[%p]: received metadata", ctx); settings.ctx = &metadata; memset(&metadata, 0, sizeof(struct metadata_s)); if (!dmap_parse(&settings, body, len)) { LOG_INFO("[%p]: received metadata\n\tartist: %s\n\talbum: %s\n\ttitle: %s", - ctx, metadata.artist, metadata.album, metadata.title); + ctx, metadata.artist ? metadata.artist : "", metadata.album ? metadata.album : "", + metadata.title ? metadata.title : ""); success = ctx->cmd_cb(RAOP_METADATA, metadata.artist, metadata.album, metadata.title); free_metadata(&metadata); } @@ -873,7 +873,7 @@ static int base64_pad(char *src, char **padded) /*----------------------------------------------------------------------------*/ static int pos(char c) { - char *p; + const char *p; for (p = base64_chars; *p; p++) if (*p == c) return p - base64_chars; @@ -959,7 +959,7 @@ static int base64_decode(const char *str, void *data) /*----------------------------------------------------------------------------*/ static void on_dmap_string(void *ctx, const char *code, const char *name, const char *buf, size_t len) { struct metadata_s *metadata = (struct metadata_s *) ctx; - // to gain space, most of the code have been removed from dmap_parser.c (define DMAP_FULL) + // to gain space, most of the code have been removed from dmap_parser.c (define DMAP_FULL if (!strcasecmp(code, "asar")) metadata->artist = strndup(buf, len); else if (!strcasecmp(code, "asal")) metadata->album = strndup(buf, len); else if (!strcasecmp(code, "minm")) metadata->title = strndup(buf, len);