avrcp: Fix error creating media items
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 5 Dec 2018 12:17:02 +0000 (09:17 -0300)
committerhimanshu <h.himanshu@samsung.com>
Wed, 22 Jan 2020 07:17:37 +0000 (12:47 +0530)
Don't use item name in the object path since it would need to be
properly escaped if the remote stack uses UID 0 even though it is
invalid to have 0 as UID:

AVRCP 1.6.1, page 84:

  'The value of UID=0x0 is a special value used only to request
   the metadata for the currently playing media using the
   GetElementAttributes command and shall not be used for any item
   in a folder.'

Change-Id: Id31a0ed0ebab207b5552466a051f1b9161d7b76b
Signed-off-by: himanshu <h.himanshu@samsung.com>
profiles/audio/player.c

index 46d95d2..2390684 100755 (executable)
@@ -1943,11 +1943,11 @@ static struct media_item *media_folder_create_item(struct media_player *mp,
        item->player = mp;
        item->uid = uid;
 
-       if (uid > 0)
+       if (!uid && name[0] == '/')
+               item->path = g_strdup_printf("%s%s", mp->path, name);
+       else
                item->path = g_strdup_printf("%s/item%" PRIu64 "",
                                                folder->item->path, uid);
-       else
-               item->path = g_strdup_printf("%s%s", mp->path, name);
 
        item->name = g_strdup(name);
        item->type = type;