From d82aec72c8e35cc730fd36e2ad48617eedc51b27 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 27 Aug 2008 12:48:33 +0200 Subject: Use bswap_32 in player --- src/player.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/player.c b/src/player.c index 462a374..86c9b70 100644 --- a/src/player.c +++ b/src/player.c @@ -26,24 +26,11 @@ THE SOFTWARE. #include #include #include +#include #include "player.h" #include "config.h" -/* LE to BE and reverse - * @param unsigned int - * @return byteswapped unsigned int - */ -unsigned int BarChangeByteorderUI32 (char buf[4]) { - unsigned int ret = 0; - - ret = buf[0] << 24 & 0xffffffff; - ret |= buf[1] << 16 & 0xffffff; - ret |= buf[2] << 8 & 0xffff; - ret |= buf[3] << 0 & 0xff; - return ret; -} - /* compute replaygain scale factor * algo taken from here: http://www.dsprelated.com/showmessage/29246/1.php * mpd does the same @@ -192,9 +179,8 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { /* how many frames do we have? */ if (player->sampleSizeN == 0) { /* mp4 uses big endian, convert */ - player->sampleSizeN = - BarChangeByteorderUI32 (player->buffer + - player->bufferRead); + player->sampleSizeN = bswap_32 (*((int *) (player->buffer + + player->bufferRead))); player->sampleSize = calloc (player->sampleSizeN, sizeof (player->sampleSizeN)); player->bufferRead += 4; @@ -202,8 +188,8 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { break; } else { player->sampleSize[player->sampleSizeCurr] = - BarChangeByteorderUI32 (player->buffer + - player->bufferRead); + bswap_32 (*((int *) (player->buffer + + player->bufferRead))); player->sampleSizeCurr++; player->bufferRead += 4; } -- cgit v1.2.3