diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/conf.h | 1 | ||||
-rw-r--r-- | src/outputBuffer.c | 20 |
4 files changed, 24 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index d4c8d57f2..d25732728 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,6 +49,7 @@ mpd_headers = \ metadataChunk.h \ mpd_types.h \ myfprintf.h \ + normalize.h \ outputBuffer.h \ path.h \ pcm_utils.h \ @@ -93,6 +94,7 @@ mpd_SOURCES = \ main.c \ metadataChunk.c \ myfprintf.c \ + normalize.c \ outputBuffer.c \ path.c \ pcm_utils.c \ diff --git a/src/conf.c b/src/conf.c index 2a0ab2077..995cbf892 100644 --- a/src/conf.c +++ b/src/conf.c @@ -171,6 +171,7 @@ void initConf(void) registerConfigParam(CONF_REPLAYGAIN_PREAMP, 0, 0); registerConfigParam(CONF_METADATA_TO_USE, 0, 0); registerConfigParam(CONF_ID3V1_ENCODING, 0, 0); + registerConfigParam(CONF_VOLUME_NORMALIZATION, 0, 0); } static void addBlockParam(ConfigParam * param, char *name, char *value, diff --git a/src/conf.h b/src/conf.h index fd68ca327..e0526b8a0 100644 --- a/src/conf.h +++ b/src/conf.h @@ -58,6 +58,7 @@ #define CONF_HTTP_PREBUFFER_SIZE "http_prebuffer_size" #define CONF_METADATA_TO_USE "metadata_to_use" #define CONF_ID3V1_ENCODING "id3v1_encoding" +#define CONF_VOLUME_NORMALIZATION "volume_normalization" typedef struct _BlockParam { char *name; 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) { |