summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-27 12:48:33 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-27 12:48:33 +0200
commitd82aec72c8e35cc730fd36e2ad48617eedc51b27 (patch)
treecf064b55e0a59dbd374bc536f92e7930209609ba /src/player.c
parentfe960fc16385a6cd9616b823603679ef26b4c4a3 (diff)
downloadpianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.tar.gz
pianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.tar.bz2
pianobar-d82aec72c8e35cc730fd36e2ad48617eedc51b27.zip
Use bswap_32 in player
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c24
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;
}