diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2012-11-17 15:50:06 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2012-11-17 15:50:06 +0100 |
commit | 12f132dd220027ee2075572d7271a5b13cfa4cbe (patch) | |
tree | cc3dba4c00e6fe8a2b5087655fa1b03d5b47174b | |
parent | cdb3ba3b567099236ebc1998b84ec0d7035d8cc8 (diff) | |
download | pianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.tar.gz pianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.tar.bz2 pianobar-windows-12f132dd220027ee2075572d7271a5b13cfa4cbe.zip |
player: Fix insane typecast
-rw-r--r-- | src/player.c | 19 |
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) { |