From c8265ec286f4ce96006a73a39f49d631316f530a Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 12 Oct 2011 12:11:20 -0300 Subject: [PATCH] AVRCP: Only return available metadata attributes When remote side requests all available metadata (i.e. it gives number attributes equals to 0) do not return zero-length strings for unavailable items. The only exception is title, that must be always present. --- audio/avrcp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/audio/avrcp.c b/audio/avrcp.c index 8b4665018..4e3ef978b 100644 --- a/audio/avrcp.c +++ b/audio/avrcp.c @@ -611,10 +611,14 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player, if (!nattr) { /* * Return all available information, at least - * title must be returned. + * title must be returned if there's a track selected. */ - for (i = 1; i < AVRCP_MEDIA_ATTRIBUTE_LAST; i++) { - size = player_get_media_attribute(player, i, + GList *l, *attr_ids = player->cb->list_metadata(player->user_data); + + for (l = attr_ids; l != NULL; l = l->next) { + uint32_t attr = GPOINTER_TO_UINT(l->data); + + size = player_get_media_attribute(player, attr, &pdu->params[pos], AVRCP_PDU_MTU - pos); @@ -623,6 +627,8 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player, pos += size; } } + + g_list_free(attr_ids); } else { uint32_t *attr_ids; -- 2.11.0