From 96493e0333404ddea739a08e1e3ead8dcb6f836c Mon Sep 17 00:00:00 2001 From: Max Kellermann <max@duempel.org> Date: Tue, 16 Feb 2010 08:55:37 +0100 Subject: 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. --- src/output_init.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src/output_init.c') 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); -- cgit v1.2.3