aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2006-07-22 00:53:37 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2006-07-22 00:53:37 +0000
commitcf90f8194fdcf4b7d3234453da00f8f3b88e54c9 (patch)
tree171cf6dc76a024d6efeea52082bdbfb12075c765 /src/outputBuffer.c
parentc4d1344f8c9ca6398317135173a01d423d315f63 (diff)
downloadmpd-cf90f8194fdcf4b7d3234453da00f8f3b88e54c9.tar.gz
mpd-cf90f8194fdcf4b7d3234453da00f8f3b88e54c9.tar.xz
mpd-cf90f8194fdcf4b7d3234453da00f8f3b88e54c9.zip
Adding on the fly volume normalization support. Code originally from mplayer, ported by syscrash, cleaned up by avuton, and further cleaned up by me (jat).
git-svn-id: https://svn.musicpd.org/mpd/trunk@4424 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r--src/outputBuffer.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 30a96bd22..02d9234fd 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -22,6 +22,8 @@
#include "playerData.h"
#include "utils.h"
#include "log.h"
+#include "normalize.h"
+#include "conf.h"
#include <string.h>
@@ -76,6 +78,22 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
size_t datalen;
static char *convBuffer = NULL;
static long convBufferLen = 0;
+ static int normalEnable = -1;
+ ConfigParam *param;
+
+ if (normalEnable == -1) {
+ normalEnable = getBoolConfigParam(CONF_VOLUME_NORMALIZATION);
+ if (normalEnable == -1) {
+ /* not set */
+ normalEnable = 0;
+ } else if (normalEnable < 0) {
+ param = getConfigParam(CONF_VOLUME_NORMALIZATION);
+ WARNING("%s is not \"yes\" or \"no\" on line %i, "
+ "disabling\n", CONF_VOLUME_NORMALIZATION,
+ param->line);
+ normalEnable = 0;
+ }
+ }
if (cmpAudioFormat(&(cb->audioFormat), &(dc->audioFormat)) == 0) {
data = dataIn;
@@ -99,6 +117,8 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
if (replayGainInfo) {
doReplayGain(replayGainInfo, data, datalen, &cb->audioFormat);
+ } else if (normalEnable) {
+ normalizeData(data, datalen, &cb->audioFormat);
}
while (datalen) {