summaryrefslogtreecommitdiff
path: root/streamer.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-24 20:24:08 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-24 20:24:08 +0200
commit981ecf8e2629d9dd2f8070097ec65bbfd23a5718 (patch)
treecbb570b9295891bd8e5d9149049c5e5cd290abf7 /streamer.c
parent5ee474966134a7e5c046504aa7899a25e10b9d43 (diff)
flac replay gain support
Diffstat (limited to 'streamer.c')
-rw-r--r--streamer.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/streamer.c b/streamer.c
index a22422ac..d1ad0bdb 100644
--- a/streamer.c
+++ b/streamer.c
@@ -392,25 +392,23 @@ apply_replay_gain_int16 (playItem_t *it, char *bytes, int size) {
}
vol = db_to_amp (str_streaming_song.replaygain_album_gain) * 1000;
}
- if (it->replaygain_track_gain != 0) {
- int16_t *s = (int16_t*)bytes;
- for (int j = 0; j < size/2; j++) {
- int32_t sample = ((int32_t)*s) * vol / 1000;
- if (sample > 0x7fff) {
- sample = 0x7fff;
- }
- else if (sample < -0x8000) {
- sample = -0x8000;
- }
- *s = (int16_t)sample;
- s++;
+ int16_t *s = (int16_t*)bytes;
+ for (int j = 0; j < size/2; j++) {
+ int32_t sample = ((int32_t)*s) * vol / 1000;
+ if (sample > 0x7fff) {
+ sample = 0x7fff;
}
+ else if (sample < -0x8000) {
+ sample = -0x8000;
+ }
+ *s = (int16_t)sample;
+ s++;
}
}
static void
apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) {
- if (!replaygain && !conf_replaygain_mode) {
+ if (!replaygain || !conf_replaygain_mode) {
return;
}
float vol = 1;
@@ -426,19 +424,17 @@ apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) {
}
vol = db_to_amp (it->replaygain_album_gain);
}
- if (it->replaygain_track_gain != 0) {
- float *s = (float*)bytes;
- for (int j = 0; j < size/4; j++) {
- float sample = ((float)*s) * vol;
- if (sample > 1.f) {
- sample = 1.f;
- }
- else if (sample < -1.f) {
- sample = -1.f;
- }
- *s = sample;
- s++;
+ float *s = (float*)bytes;
+ for (int j = 0; j < size/4; j++) {
+ float sample = ((float)*s) * vol;
+ if (sample > 1.f) {
+ sample = 1.f;
+ }
+ else if (sample < -1.f) {
+ sample = -1.f;
}
+ *s = sample;
+ s++;
}
}