diff options
author | Max Kellermann <max@duempel.org> | 2013-08-04 13:43:36 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-04 14:07:50 +0200 |
commit | a0beb5fa26e2b66d01a3b21534b848930929a333 (patch) | |
tree | eb6e661a05b5d9994f514a6fbcc50a72d94df722 | |
parent | f54bcc1f16f815fb507ac8a8ffd7913f686969d2 (diff) | |
download | mpd-a0beb5fa26e2b66d01a3b21534b848930929a333.tar.gz mpd-a0beb5fa26e2b66d01a3b21534b848930929a333.tar.xz mpd-a0beb5fa26e2b66d01a3b21534b848930929a333.zip |
MixerPlugin: pass config_param reference
Diffstat (limited to '')
-rw-r--r-- | src/MixerControl.cxx | 2 | ||||
-rw-r--r-- | src/MixerControl.hxx | 2 | ||||
-rw-r--r-- | src/MixerPlugin.hxx | 5 | ||||
-rw-r--r-- | src/OutputInit.cxx | 6 | ||||
-rw-r--r-- | src/mixer/AlsaMixerPlugin.cxx | 20 | ||||
-rw-r--r-- | src/mixer/OssMixerPlugin.cxx | 10 | ||||
-rw-r--r-- | src/mixer/PulseMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/RoarMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/SoftwareMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/WinmmMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | test/read_mixer.cxx | 4 |
11 files changed, 30 insertions, 27 deletions
diff --git a/src/MixerControl.cxx b/src/MixerControl.cxx index 8a3fbd6b3..bbb3ede2c 100644 --- a/src/MixerControl.cxx +++ b/src/MixerControl.cxx @@ -31,7 +31,7 @@ Mixer * mixer_new(const struct mixer_plugin *plugin, void *ao, - const struct config_param *param, + const config_param ¶m, GError **error_r) { Mixer *mixer; diff --git a/src/MixerControl.hxx b/src/MixerControl.hxx index 1e01e111a..e7b65d6e8 100644 --- a/src/MixerControl.hxx +++ b/src/MixerControl.hxx @@ -37,7 +37,7 @@ extern "C" { Mixer * mixer_new(const struct mixer_plugin *plugin, void *ao, - const struct config_param *param, + const config_param ¶m, GError **error_r); void diff --git a/src/MixerPlugin.hxx b/src/MixerPlugin.hxx index a43c34fc4..e80ae094e 100644 --- a/src/MixerPlugin.hxx +++ b/src/MixerPlugin.hxx @@ -37,13 +37,12 @@ struct mixer_plugin { * Alocates and configures a mixer device. * * @param ao the pointer returned by audio_output_plugin.init - * @param param the configuration section, or NULL if there is - * no configuration + * @param param the configuration section * @param error_r location to store the error occurring, or * NULL to ignore errors * @return a mixer object, or NULL on error */ - Mixer *(*init)(void *ao, const struct config_param *param, + Mixer *(*init)(void *ao, const config_param ¶m, GError **error_r); /** diff --git a/src/OutputInit.cxx b/src/OutputInit.cxx index 053e1e633..2e50515c8 100644 --- a/src/OutputInit.cxx +++ b/src/OutputInit.cxx @@ -112,10 +112,12 @@ audio_output_load_mixer(struct audio_output *ao, if (plugin == NULL) return NULL; - return mixer_new(plugin, ao, ¶m, error_r); + return mixer_new(plugin, ao, param, error_r); case MIXER_TYPE_SOFTWARE: - mixer = mixer_new(&software_mixer_plugin, NULL, NULL, NULL); + mixer = mixer_new(&software_mixer_plugin, nullptr, + config_param(), + nullptr); assert(mixer != NULL); filter_chain_append(filter_chain, "software_mixer", diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx index a78b83f8a..31e9997e3 100644 --- a/src/mixer/AlsaMixerPlugin.cxx +++ b/src/mixer/AlsaMixerPlugin.cxx @@ -31,7 +31,7 @@ #define VOLUME_MIXER_ALSA_DEFAULT "default" #define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM" -#define VOLUME_MIXER_ALSA_INDEX_DEFAULT 0 +static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0; class AlsaMixerMonitor final : private MultiSocketMonitor { snd_mixer_t *const mixer; @@ -61,7 +61,7 @@ class AlsaMixer final : public Mixer { public: AlsaMixer():Mixer(alsa_mixer_plugin) {} - void Configure(const config_param *param); + void Configure(const config_param ¶m); bool Setup(GError **error_r); bool Open(GError **error_r); void Close(); @@ -138,18 +138,18 @@ alsa_mixer_elem_callback(G_GNUC_UNUSED snd_mixer_elem_t *elem, unsigned mask) */ inline void -AlsaMixer::Configure(const config_param *param) +AlsaMixer::Configure(const config_param ¶m) { - device = config_get_block_string(param, "mixer_device", - VOLUME_MIXER_ALSA_DEFAULT); - control = config_get_block_string(param, "mixer_control", - VOLUME_MIXER_ALSA_CONTROL_DEFAULT); - index = config_get_block_unsigned(param, "mixer_index", - VOLUME_MIXER_ALSA_INDEX_DEFAULT); + device = param.GetBlockValue("mixer_device", + VOLUME_MIXER_ALSA_DEFAULT); + control = param.GetBlockValue("mixer_control", + VOLUME_MIXER_ALSA_CONTROL_DEFAULT); + index = param.GetBlockValue("mixer_index", + VOLUME_MIXER_ALSA_INDEX_DEFAULT); } static Mixer * -alsa_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param, +alsa_mixer_init(G_GNUC_UNUSED void *ao, const config_param ¶m, G_GNUC_UNUSED GError **error_r) { AlsaMixer *am = new AlsaMixer(); diff --git a/src/mixer/OssMixerPlugin.cxx b/src/mixer/OssMixerPlugin.cxx index 5c2bdec8d..bbb5b6c88 100644 --- a/src/mixer/OssMixerPlugin.cxx +++ b/src/mixer/OssMixerPlugin.cxx @@ -51,7 +51,7 @@ class OssMixer : public Mixer { public: OssMixer():Mixer(oss_mixer_plugin) {} - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); bool Open(GError **error_r); void Close(); @@ -84,11 +84,11 @@ oss_find_mixer(const char *name) } inline bool -OssMixer::Configure(const config_param *param, GError **error_r) +OssMixer::Configure(const config_param ¶m, GError **error_r) { - device = config_get_block_string(param, "mixer_device", + device = param.GetBlockValue("mixer_device", VOLUME_MIXER_OSS_DEFAULT); - control = config_get_block_string(param, "mixer_control", NULL); + control = param.GetBlockValue("mixer_control"); if (control != NULL) { volume_control = oss_find_mixer(control); @@ -104,7 +104,7 @@ OssMixer::Configure(const config_param *param, GError **error_r) } static Mixer * -oss_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param, +oss_mixer_init(G_GNUC_UNUSED void *ao, const config_param ¶m, GError **error_r) { OssMixer *om = new OssMixer(); diff --git a/src/mixer/PulseMixerPlugin.cxx b/src/mixer/PulseMixerPlugin.cxx index 389f077f3..9cfd2dcf8 100644 --- a/src/mixer/PulseMixerPlugin.cxx +++ b/src/mixer/PulseMixerPlugin.cxx @@ -153,7 +153,7 @@ pulse_mixer_on_change(PulseMixer *pm, } static Mixer * -pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param, +pulse_mixer_init(void *ao, gcc_unused const config_param ¶m, GError **error_r) { PulseOutput *po = (PulseOutput *)ao; diff --git a/src/mixer/RoarMixerPlugin.cxx b/src/mixer/RoarMixerPlugin.cxx index 92a22f51b..90d54ddaa 100644 --- a/src/mixer/RoarMixerPlugin.cxx +++ b/src/mixer/RoarMixerPlugin.cxx @@ -34,7 +34,7 @@ struct RoarMixer final : public Mixer { }; static Mixer * -roar_mixer_init(void *ao, gcc_unused const struct config_param *param, +roar_mixer_init(void *ao, gcc_unused const config_param ¶m, gcc_unused GError **error_r) { return new RoarMixer((RoarOutput *)ao); diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx index bb0b890ca..8a268aaf1 100644 --- a/src/mixer/SoftwareMixerPlugin.cxx +++ b/src/mixer/SoftwareMixerPlugin.cxx @@ -51,7 +51,7 @@ struct SoftwareMixer final : public Mixer { static Mixer * software_mixer_init(gcc_unused void *ao, - gcc_unused const struct config_param *param, + gcc_unused const config_param ¶m, gcc_unused GError **error_r) { return new SoftwareMixer(); diff --git a/src/mixer/WinmmMixerPlugin.cxx b/src/mixer/WinmmMixerPlugin.cxx index 89ed854ae..139cb1399 100644 --- a/src/mixer/WinmmMixerPlugin.cxx +++ b/src/mixer/WinmmMixerPlugin.cxx @@ -60,7 +60,7 @@ winmm_volume_encode(int volume) } static Mixer * -winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param, +winmm_mixer_init(void *ao, gcc_unused const config_param ¶m, G_GNUC_UNUSED GError **error_r) { assert(ao != nullptr); diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx index 1d8372a98..54c92eea3 100644 --- a/test/read_mixer.cxx +++ b/test/read_mixer.cxx @@ -25,6 +25,7 @@ #include "GlobalEvents.hxx" #include "Main.hxx" #include "event/Loop.hxx" +#include "ConfigData.hxx" #include <glib.h> @@ -125,7 +126,8 @@ int main(int argc, G_GNUC_UNUSED char **argv) main_loop = new EventLoop(EventLoop::Default()); - Mixer *mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &error); + Mixer *mixer = mixer_new(&alsa_mixer_plugin, nullptr, + config_param(), &error); if (mixer == NULL) { g_printerr("mixer_new() failed: %s\n", error->message); g_error_free(error); |