AVRCP: Handler player features as a byte array
Luiz Augusto von Dentz
maintainerPATCH 1/1 AVRCP: Handler player features as a byte array
From: Luiz Augusto von Dentz <[email protected]>
This way we can direct match by byte which is how the spec represent them.
--- profiles/audio/avrcp.c | 5 ++--- profiles/audio/player.c | 16 ++++++++++++---- profiles/audio/player.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-)
profiles/audio/avrcp.c +2 -3
@@ -1983,7 +1983,7 @@ static void avrcp_parse_media_player_item(struct avrcp *session,uint16_t id;uint32_t subtype;const char *curval, *strval; -uint64_t features[2 ]; +uint8_t features[16 ];char name[255 ];if (len <28 )
@@ -2008,8 +2008,7 @@ static void avrcp_parse_media_player_item(struct avrcp *session,avrcp_get_play_status (session); } - features[0 ] =bt_get_be64 (&operands[8 ]); - features[1 ] =bt_get_be64 (&operands[16 ]); +memcpy (features, &operands[8 ],sizeof (features));media_player_set_features (mp, features);
profiles/audio/player.c +12 -4
@@ -67,7 +67,7 @@ struct media_player {char *name;/* Player name */ char *type;/* Player type */ char *subtype;/* Player subtype */ -uint64_t features[2 ];/* Player features */ +uint8_t *features;/* Player features */ struct media_folder *folder;/* Player currenct folder */ char *path;/* Player object path */ GHashTable *settings;/* Player settings */
@@ -644,6 +644,7 @@ void media_player_destroy(struct media_player *mp)g_free (mp->subtype);g_free (mp->type);g_free (mp->name); +g_free (mp->features);g_free (mp); }
@@ -870,11 +871,18 @@ void media_player_set_folder(struct media_player *mp, const char *path, } } -void media_player_set_features (struct media_player *mp,uint64_t *features) +void media_player_set_features (struct media_player *mp,uint8_t *features) { -DBG ("0x%016" PRIx64"%016" PRIx64, features[0 ], features[1 ]); +DBG ("0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" +"%02x" , features[0 ], features[1 ], features[2 ], features[3 ], + features[4 ], features[5 ], features[6 ], features[7 ], + features[8 ], features[9 ], features[10 ], features[11 ], + features[12 ], features[13 ], features[14 ], features[15 ]); -memcpy (features, mp->features,sizeof (mp->features)); +if (mp->features !=NULL ) +return ; + + mp->features =g_memdup (features,16 ); } void media_player_set_callbacks(struct media_player *mp,
profiles/audio/player.h +1 -1
@@ -49,7 +49,7 @@ void media_player_set_metadata(struct media_player *mp, const char *key, void *data, size_t len);void media_player_set_type (struct media_player *mp,const char *type);void media_player_set_subtype (struct media_player *mp,const char *subtype); -void media_player_set_features (struct media_player *mp,uint64_t *features); +void media_player_set_features (struct media_player *mp,uint8_t *features);void media_player_set_name (struct media_player *mp,const char *name);void media_player_set_folder (struct media_player *mp,const char *path,uint32_t items);
Signature · 1 line
1.8.1
Hi Luiz,
profiles/audio/player.c struct media_player { · line 70
Quoted 8 lines · Luiz Augusto von Dentz
profiles/audio/player.c +1
-1@@ -67,7 +67,7 @@ struct media_player {char *name;/* Player name */ char *type;/* Player type */ char *subtype;/* Player subtype */ -uint64_t features[2 ];/* Player features */ +uint8_t *features;/* Player features */
Why not just have this as features[16] here as well so you don't need to do g_memdup and g_free?
Johan
Luiz Augusto von Dentz
maintainerHi Johan,
Quoted 14 lines · Johan Hedberg
Hi Luiz,
profiles/audio/player.c struct media_player { · line 70
Quoted 8 lines · Luiz Augusto von Dentz
profiles/audio/player.c +1
-1@@ -67,7 +67,7 @@ struct media_player {char *name;/* Player name */ char *type;/* Player type */ char *subtype;/* Player subtype */ -uint64_t features[2 ];/* Player features */ +uint8_t *features;/* Player features */ Why not just have this as features[16] here as well so you don't need to do
g_memdupandg_free?
I was planning to have a NULL check if the features are valid.
--
Luiz Augusto von Dentz
Marcel Holtmann
maintainerHi Luiz,
Quoted 12 lines
Quoted 11 lines
profiles/audio/player.c struct media_player { · line 70
Quoted 8 lines
profiles/audio/player.c +1
-1@@ -67,7 +67,7 @@ struct media_player {char *name;/* Player name */ char *type;/* Player type */ char *subtype;/* Player subtype */ -uint64_t features[2 ];/* Player features */ +uint8_t *features;/* Player features */ Why not just have this as features[16] here as well so you don't need to do
g_memdupandg_free?
Quoted 1 line
I was planning to have a NULL check if the features are valid.
actually I like to decrease the number of extra memory allocations. So what benefit is the test for features giving you actually.
Regards
Marcel
Luiz Augusto von Dentz
maintainerHi Marcel,
Quoted 14 lines · Marcel Holtmann
Hi Luiz,
Quoted 12 lines
Quoted 11 lines
profiles/audio/player.c struct media_player { · line 70
Quoted 8 lines
profiles/audio/player.c +1
-1@@ -67,7 +67,7 @@ struct media_player {char *name;/* Player name */ char *type;/* Player type */ char *subtype;/* Player subtype */ -uint64_t features[2 ];/* Player features */ +uint8_t *features;/* Player features */ Why not just have this as features[16] here as well so you don't need to do
g_memdupandg_free?
Quoted 4 lines
Quoted 1 line
I was planning to have a NULL check if the features are valid.
actually I like to decrease the number of extra memory allocations. So what benefit is the test for features giving you actually.
I would use it to differentiate players which can provide this information from those who don't, for certain commands we can reject based on the features but it has to be valid otherwise we just don't know if it is supported and should send the command anyway.
--
Luiz Augusto von Dentz