summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-24 17:08:37 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-24 17:08:37 +0200
commitd5e0af6abf7f9021094a55e00d885d05a209bef4 (patch)
tree19d91e3b6727050fc5253fdae1735cb9c0196f22 /src/player.c
parentfbb8b7d79341d077fae3c4d2d609ca3b9059e160 (diff)
downloadpianobar-d5e0af6abf7f9021094a55e00d885d05a209bef4.tar.gz
pianobar-d5e0af6abf7f9021094a55e00d885d05a209bef4.tar.bz2
pianobar-d5e0af6abf7f9021094a55e00d885d05a209bef4.zip
Reduce cpu load produced by replaygain
It's not necessary to re-compute the scale factor as it will be the same every time.
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/player.c b/src/player.c
index 086fcad..f2403bc 100644
--- a/src/player.c
+++ b/src/player.c
@@ -105,8 +105,7 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
int tmpReplayBuf;
size_t i;
for (i = 0; i < frameInfo.samples; i++) {
- tmpReplayBuf = (float) (replayBuf[i]) *
- computeReplayGainScale (player->gain);
+ tmpReplayBuf = (float) replayBuf[i] * player->scale;
/* avoid clipping */
if (tmpReplayBuf > INT16_MAX) {
replayBuf[i] = INT16_MAX;
@@ -249,6 +248,9 @@ void *BarPlayerThread (void *data) {
/* init handles */
player->audioFd = curl_easy_init ();
player->aacHandle = NeAACDecOpen();
+
+ /* init replaygain */
+ player->scale = computeReplayGainScale (player->gain);
/* set aac conf */
conf = NeAACDecGetCurrentConfiguration(player->aacHandle);