summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-11-17 15:50:06 +0100
committerLars-Dominik Braun <lars@6xq.net>2012-11-17 15:50:06 +0100
commit12f132dd220027ee2075572d7271a5b13cfa4cbe (patch)
treecc3dba4c00e6fe8a2b5087655fa1b03d5b47174b /src
parentcdb3ba3b567099236ebc1998b84ec0d7035d8cc8 (diff)
downloadpianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.tar.gz
pianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.tar.bz2
pianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.zip
player: Fix insane typecast
Diffstat (limited to 'src')
-rw-r--r--src/player.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/player.c b/src/player.c
index 92524c7..1cb44de 100644
--- a/src/player.c
+++ b/src/player.c
@@ -249,12 +249,15 @@ static WaitressCbReturn_t BarPlayerAACCb (void *ptr, size_t size,
/* how many frames do we have? */
if (player->sampleSizeN == 0) {
/* mp4 uses big endian, convert */
+ memcpy (&player->sampleSizeN, player->buffer +
+ player->bufferRead, sizeof (uint32_t));
player->sampleSizeN =
- bigToHostEndian32 (*((uint32_t *) (player->buffer +
- player->bufferRead)));
+ bigToHostEndian32 (player->sampleSizeN);
+
player->sampleSize = malloc (player->sampleSizeN *
sizeof (*player->sampleSize));
- player->bufferRead += 4;
+ assert (player->sampleSize != NULL);
+ player->bufferRead += sizeof (uint32_t);
player->sampleSizeCurr = 0;
/* set up song duration (assuming one frame always contains
* the same number of samples)
@@ -267,11 +270,15 @@ static WaitressCbReturn_t BarPlayerAACCb (void *ptr, size_t size,
(unsigned long long int) player->channels;
break;
} else {
+ memcpy (&player->sampleSize[player->sampleSizeCurr],
+ player->buffer + player->bufferRead,
+ sizeof (uint32_t));
player->sampleSize[player->sampleSizeCurr] =
- bigToHostEndian32 (*((uint32_t *) (player->buffer +
- player->bufferRead)));
+ bigToHostEndian32 (
+ player->sampleSize[player->sampleSizeCurr]);
+
player->sampleSizeCurr++;
- player->bufferRead += 4;
+ player->bufferRead += sizeof (uint32_t);
}
/* all sizes read, nearly ready for data mode */
if (player->sampleSizeCurr >= player->sampleSizeN) {