summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-27 12:33:21 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-08-27 12:33:21 +0200
commitfe960fc16385a6cd9616b823603679ef26b4c4a3 (patch)
tree13efde78ee3d038b52bb07e7577eb5d4d93e206a /src
parent6261a865d94f28b2fb6f06716178e22192176e17 (diff)
downloadpianobar-windows-fe960fc16385a6cd9616b823603679ef26b4c4a3.tar.gz
pianobar-windows-fe960fc16385a6cd9616b823603679ef26b4c4a3.tar.bz2
pianobar-windows-fe960fc16385a6cd9616b823603679ef26b4c4a3.zip
AAC-Player fine tuning
Move variables definitions outside the loop, define buffer as short int, as replaygain works with ints, not bytes.
Diffstat (limited to 'src')
-rw-r--r--src/player.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/player.c b/src/player.c
index 4d42b91..462a374 100644
--- a/src/player.c
+++ b/src/player.c
@@ -89,8 +89,10 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
player->bufferRead = 0;
if (player->mode == PLAYER_RECV_DATA) {
- char *aacDecoded;
+ short int *aacDecoded;
NeAACDecFrameInfo frameInfo;
+ int tmpReplayBuf;
+ size_t i;
while ((player->bufferFilled - player->bufferRead) >
player->sampleSize[player->sampleSizeCurr]) {
@@ -103,22 +105,19 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
NeAACDecGetErrorMessage (frameInfo.error));
break;
}
- short int *replayBuf = (short int *) aacDecoded;
- int tmpReplayBuf;
- size_t i;
for (i = 0; i < frameInfo.samples; i++) {
- tmpReplayBuf = (float) replayBuf[i] * player->scale;
+ tmpReplayBuf = (float) aacDecoded[i] * player->scale;
/* avoid clipping */
if (tmpReplayBuf > INT16_MAX) {
- replayBuf[i] = INT16_MAX;
+ aacDecoded[i] = INT16_MAX;
} else if (tmpReplayBuf < INT16_MIN) {
- replayBuf[i] = INT16_MIN;
+ aacDecoded[i] = INT16_MIN;
} else {
- replayBuf[i] = tmpReplayBuf;
+ aacDecoded[i] = tmpReplayBuf;
}
}
/* ao_play needs bytes: 1 sample = 16 bits = 2 bytes */
- ao_play (player->audioOutDevice, aacDecoded,
+ ao_play (player->audioOutDevice, (char *) aacDecoded,
frameInfo.samples * 16 / 8);
player->bufferRead += frameInfo.bytesconsumed;
player->sampleSizeCurr++;