aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_init.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-06 22:00:50 +0200
committerMax Kellermann <max@duempel.org>2009-07-06 22:00:50 +0200
commit0275690b5cd133f992e9e34d6c76eb134aef26bd (patch)
tree3ce67839d522420ff7b99224cdc8892c86395036 /src/output_init.c
parentda8095db546544bb9fe3a455ef5742bfef9c2f4f (diff)
downloadmpd-0275690b5cd133f992e9e34d6c76eb134aef26bd.tar.gz
mpd-0275690b5cd133f992e9e34d6c76eb134aef26bd.tar.xz
mpd-0275690b5cd133f992e9e34d6c76eb134aef26bd.zip
output: use the software mixer plugin
Do all the software volume stuff inside each output thread, not in the player thread. This allows one software mixer per output device, and also allows the user to configure the mixer type (hardware or software) for each audio output. This moves the global "mixer_type" setting into the "audio_output" section, deprecating the "mixer_enabled" flag.
Diffstat (limited to '')
-rw-r--r--src/output_init.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/output_init.c b/src/output_init.c
index eba665e77..08873ac20 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -23,6 +23,9 @@
#include "output_list.h"
#include "audio_parser.h"
#include "mixer_control.h"
+#include "mixer_type.h"
+#include "mixer_list.h"
+#include "mixer/software_mixer_plugin.h"
#include "filter_plugin.h"
#include "filter_registry.h"
#include "filter/chain_filter_plugin.h"
@@ -61,17 +64,59 @@ audio_output_detect(GError **error)
return NULL;
}
+/**
+ * Determines the mixer type which should be used for the specified
+ * configuration block.
+ *
+ * This handles the deprecated options mixer_type (global) and
+ * mixer_enabled, if the mixer_type setting is not configured.
+ */
+static enum mixer_type
+audio_output_mixer_type(const struct config_param *param)
+{
+ /* read the local "mixer_type" setting */
+ const char *p = config_get_block_string(param, "mixer_type", NULL);
+ if (p != NULL)
+ return mixer_type_parse(p);
+
+ /* try the local "mixer_enabled" setting next (deprecated) */
+ if (!config_get_block_bool(param, "mixer_enabled", true))
+ return MIXER_TYPE_NONE;
+
+ /* fall back to the global "mixer_type" setting (also
+ deprecated) */
+ return mixer_type_parse(config_get_string("mixer_type", "hardware"));
+}
+
static struct mixer *
audio_output_load_mixer(const struct config_param *param,
- const struct mixer_plugin *plugin)
+ const struct mixer_plugin *plugin,
+ struct filter *filter_chain)
{
- if (!config_get_block_bool(param, "mixer_enabled", true))
- return NULL;
+ struct mixer *mixer;
- if (plugin == NULL)
+ switch (audio_output_mixer_type(param)) {
+ case MIXER_TYPE_NONE:
+ case MIXER_TYPE_UNKNOWN:
return NULL;
- return mixer_new(plugin, param);
+ case MIXER_TYPE_HARDWARE:
+ if (plugin == NULL)
+ return NULL;
+
+ return mixer_new(plugin, param);
+
+ case MIXER_TYPE_SOFTWARE:
+ mixer = mixer_new(&software_mixer_plugin, NULL);
+ assert(mixer != NULL);
+
+ filter_chain_append(filter_chain,
+ software_mixer_get_filter(mixer));
+ return mixer;
+ }
+
+ assert(false);
+ return NULL;
}
bool
@@ -152,7 +197,8 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
if (ao->data == NULL)
return false;
- ao->mixer = audio_output_load_mixer(param, plugin->mixer_plugin);
+ ao->mixer = audio_output_load_mixer(param, plugin->mixer_plugin,
+ ao->filter);
/* the "convert" filter must be the last one in the chain */