diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-08-27 12:48:33 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-08-27 12:48:33 +0200 |
commit | d82aec72c8e35cc730fd36e2ad48617eedc51b27 (patch) | |
tree | cf064b55e0a59dbd374bc536f92e7930209609ba /src | |
parent | fe960fc16385a6cd9616b823603679ef26b4c4a3 (diff) | |
download | pianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.tar.gz pianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.tar.bz2 pianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.zip |
Use bswap_32 in player
Diffstat (limited to 'src')
-rw-r--r-- | src/player.c | 24 |
1 files changed, 5 insertions, 19 deletions
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 <string.h> #include <math.h> #include <stdint.h> +#include <byteswap.h> #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; } |