diff options
author | Max Kellermann <max@duempel.org> | 2010-02-16 08:55:37 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-02-17 08:14:07 +0100 |
commit | 96493e0333404ddea739a08e1e3ead8dcb6f836c (patch) | |
tree | 5c953ea3a3b5f7f22174e6046a6b107390524438 /src/output_init.c | |
parent | 48b49e230352de10bb3f66a1c85d367dade52001 (diff) | |
download | mpd-96493e0333404ddea739a08e1e3ead8dcb6f836c.tar.gz mpd-96493e0333404ddea739a08e1e3ead8dcb6f836c.tar.xz mpd-96493e0333404ddea739a08e1e3ead8dcb6f836c.zip |
replay_gain: optionally use hardware mixer to apply replay gain
Add an option for each audio output which enables the use of the
hardware mixer, instead of the software volume code.
This is hardware specific, and assumes linear volume control. This is
not the case for hardware mixers which were tested, making this patch
somewhat useless, but we will use it to experiment with the settings,
to find a good solution.
Diffstat (limited to 'src/output_init.c')
-rw-r--r-- | src/output_init.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/output_init.c b/src/output_init.c index 387915ddc..f3d22ace1 100644 --- a/src/output_init.c +++ b/src/output_init.c @@ -32,6 +32,7 @@ #include "filter_config.h" #include "filter/chain_filter_plugin.h" #include "filter/autoconvert_filter_plugin.h" +#include "filter/replay_gain_filter_plugin.h" #include <glib.h> @@ -196,12 +197,19 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, /* create the replay_gain filter */ - ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin, - param, NULL); - assert(ao->replay_gain_filter != NULL); + const char *replay_gain_handler = + config_get_block_string(param, "replay_gain_handler", + "software"); - filter_chain_append(ao->filter, ao->replay_gain_filter); - ao->replay_gain_serial = 0; + if (strcmp(replay_gain_handler, "none") != 0) { + ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin, + param, NULL); + assert(ao->replay_gain_filter != NULL); + + filter_chain_append(ao->filter, ao->replay_gain_filter); + ao->replay_gain_serial = 0; + } else + ao->replay_gain_filter = NULL; /* create the normalization filter (if configured) */ @@ -247,6 +255,21 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, g_error_free(error); } + /* use the hardware mixer for replay gain? */ + + if (strcmp(replay_gain_handler, "mixer") == 0) { + if (ao->mixer != NULL) + replay_gain_filter_set_mixer(ao->replay_gain_filter, + ao->mixer, 100); + else + g_warning("No such mixer for output '%s'", ao->name); + } else if (strcmp(replay_gain_handler, "software") != 0 && + ao->replay_gain_filter != NULL) { + g_set_error(error_r, audio_output_quark(), 0, + "Invalid \"replay_gain_handler\" value"); + return false; + } + /* the "convert" filter must be the last one in the chain */ ao->convert_filter = filter_new(&convert_filter_plugin, NULL, NULL); |