Re: [PATCH BlueZ 03/10 v3] player: Add defines for item types and folder types

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

 



Hi Luiz,

On Fri, Mar 01, 2013, Luiz Augusto von Dentz wrote:
> On Fri, Mar 1, 2013 at 1:20 PM, Johan Hedberg <johan.hedberg@xxxxxxxxx> wrote:
> > Hi Luiz,
> >
> > On Thu, Feb 28, 2013, Luiz Augusto von Dentz wrote:
> >> +static const char *type_to_string(uint8_t type)
> >> +{
> >> +     switch (type) {
> >> +     case PLAYER_ITEM_TYPE_AUDIO:
> >> +             return "audio";
> >> +     case PLAYER_ITEM_TYPE_VIDEO:
> >> +             return "video";
> >> +     case PLAYER_ITEM_TYPE_FOLDER:
> >> +             return "folder";
> >> +     }
> >> +
> >> +     return NULL;
> >> +}
> >> +
> >>
> >> +static const char *folder_type_to_string(uint8_t type)
> >> +{
> >> +     switch (type) {
> >> +     case PLAYER_FOLDER_TYPE_MIXED:
> >> +             return "mixed";
> >> +     case PLAYER_FOLDER_TYPE_TITLES:
> >> +             return "titles";
> >> +     case PLAYER_FOLDER_TYPE_ALBUMS:
> >> +             return "albums";
> >> +     case PLAYER_FOLDER_TYPE_ARTISTS:
> >> +             return "artists";
> >> +     case PLAYER_FOLDER_TYPE_GENRES:
> >> +             return "genres";
> >> +     case PLAYER_FOLDER_TYPE_PLAYLISTS:
> >> +             return "playlists";
> >> +     case PLAYER_FOLDER_TYPE_YEARS:
> >> +             return "years";
> >> +     }
> >> +
> >> +     return NULL;
> >> +}
> >> diff --git a/profiles/audio/player.h b/profiles/audio/player.h
> >> index 28689c5..9888f56 100644
> >> --- a/profiles/audio/player.h
> >> +++ b/profiles/audio/player.h
> >> @@ -23,6 +23,20 @@
> >>   *
> >>   */
> >>
> >> +#define PLAYER_ITEM_TYPE_AUDIO               0x00
> >> +#define PLAYER_ITEM_TYPE_VIDEO               0x01
> >> +#define PLAYER_ITEM_TYPE_FOLDER              0x02
> >> +#define PLAYER_ITEM_TYPE_INVALID     0xff
> >> +
> >> +#define PLAYER_FOLDER_TYPE_MIXED     0x00
> >> +#define PLAYER_FOLDER_TYPE_TITLES    0x01
> >> +#define PLAYER_FOLDER_TYPE_ALBUMS    0x02
> >> +#define PLAYER_FOLDER_TYPE_ARTISTS   0x03
> >> +#define PLAYER_FOLDER_TYPE_GENRES    0x04
> >> +#define PLAYER_FOLDER_TYPE_PLAYLISTS 0x05
> >> +#define PLAYER_FOLDER_TYPE_YEARS     0x06
> >> +#define PLAYER_FOLDER_TYPE_INVALID   0xff
> >
> > Why not enums? That'd let the compiler verify that all values are
> > covered in switch statements and since this is an internal API and not a
> > protocol detail there really isn't a need to use a fixed size integer
> > (uint8_t).
> 
> Well I was expecting it should follow the AVRCP spec, otherwise we are
> always going to have to do 2 conversions: AVRCP <-> enum <-> string.

There is no AVRCP correspondence at least for the item type where you've
molded two protocol concepts together into one value. Also, using an
enum doesn't mean that you can't use protocol values.

Johan
--
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