From 34207c770a372a5d847fe60423dc82a358faab6b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 27 Aug 2007 13:38:17 +0000 Subject: Make SBC frame header endian safe --- sbc/sbcinfo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sbc/sbcinfo.c b/sbc/sbcinfo.c index e34f5618..e8fb398f 100644 --- a/sbc/sbcinfo.c +++ b/sbc/sbcinfo.c @@ -34,6 +34,7 @@ #include #include +#if __BYTE_ORDER == __LITTLE_ENDIAN struct sbc_frame_hdr { uint8_t syncword:8; /* Sync word */ uint8_t subbands:1; /* Subbands */ @@ -44,6 +45,20 @@ struct sbc_frame_hdr { uint8_t bitpool:8; /* Bitpool */ uint8_t crc_check:8; /* CRC check */ } __attribute__ ((packed)); +#elif __BYTE_ORDER == __BIG_ENDIAN +struct sbc_frame_hdr { + uint8_t syncword:8; /* Sync word */ + uint8_t sampling_frequency:2; /* Sampling frequency */ + uint8_t blocks:2; /* Blocks */ + uint8_t channel_mode:2; /* Channel mode */ + uint8_t allocation_method:1; /* Allocation method */ + uint8_t subbands:1; /* Subbands */ + uint8_t bitpool:8; /* Bitpool */ + uint8_t crc_check:8; /* CRC check */ +} __attribute__ ((packed)); +#else +#error "Unknown byte order" +#endif static int calc_frame_len(struct sbc_frame_hdr *hdr) { -- cgit