OSDN Git Service

AVRCP: Only return available metadata attributes
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 12 Oct 2011 15:11:20 +0000 (12:11 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 13 Oct 2011 10:10:13 +0000 (13:10 +0300)
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

index 8b46650..4e3ef97 100644 (file)
@@ -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;