Re: [PATCH BlueZ 1/2] AVRCP: Fix using void * for metadata values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lucas,

On Tue, Oct 16, 2012 at 3:56 PM, Lucas De Marchi
<lucas.demarchi@xxxxxxxxxxxxxx> wrote:
> Hi Luiz
>
> On Tue, Oct 16, 2012 at 8:58 AM, Luiz Augusto von Dentz
> <luiz.dentz@xxxxxxxxx> wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
>>
>> This replaces get_metadata callback with get_string and get_uint32
>> which uses proper types as return.
>> ---
>
> I fail to see what this commit is fixing. It seems more like
> refactoring void* to explicit types.
>
>
>>  audio/avrcp.c | 32 ++++++++++++++++++--------------
>>  audio/avrcp.h |  3 ++-
>>  audio/media.c | 31 ++++++++++++++++++++++++-------
>>  3 files changed, 44 insertions(+), 22 deletions(-)
>>
>> diff --git a/audio/avrcp.c b/audio/avrcp.c
>> index 2f5df21..5a18cb4 100644
>> --- a/audio/avrcp.c
>> +++ b/audio/avrcp.c
>> @@ -501,23 +501,29 @@ static uint16_t player_write_media_attribute(struct avrcp_player *player,
>>         uint16_t len;
>>         uint16_t attr_len;
>>         char valstr[20];
>> -       void *value;
>> +       const char *value = NULL;
>> +       uint32_t num;
>>
>>         DBG("%u", id);
>>
>> -       value = player->cb->get_metadata(id, player->user_data);
>> -       if (value == NULL) {
>> -               *offset = 0;
>> -               return 0;
>> -       }
>> -
>>         switch (id) {
>>         case AVRCP_MEDIA_ATTRIBUTE_TRACK:
>>         case AVRCP_MEDIA_ATTRIBUTE_N_TRACKS:
>>         case AVRCP_MEDIA_ATTRIBUTE_DURATION:
>> -               snprintf(valstr, 20, "%u", GPOINTER_TO_UINT(value));
>> +               num = player->cb->get_uint32(id, player->user_data);
>> +               if (num == 0)
>> +                       break;
>> +
>> +               snprintf(valstr, 20, "%u", num);
>
> The downside here is that we loose the ability to differentiate
> attribute not present from the value 0. 0 doesn't make sense for
> duration, but is a valid value for the other 2.

Which ones? You mean track and track number, I guess we can skip those
if they are 0.

-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux