aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer/alsa_mixer.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-25 17:38:12 +0100
committerMax Kellermann <max@duempel.org>2009-01-25 17:38:12 +0100
commitdc575106c296435940482cc2655804c71ee2d934 (patch)
tree4c5a455e28a224fdab697c4b00f34305b2e67281 /src/mixer/alsa_mixer.c
parentdb2058a26580681911aed09b427472ccde0176dd (diff)
downloadmpd-dc575106c296435940482cc2655804c71ee2d934.tar.gz
mpd-dc575106c296435940482cc2655804c71ee2d934.tar.xz
mpd-dc575106c296435940482cc2655804c71ee2d934.zip
mixer: merged methods "init" and "configure"
Both methods are always called together. There is no point in having them separate. This simplifies the code, because the old configure() method could be called more than once, and had to free old allocations.
Diffstat (limited to '')
-rw-r--r--src/mixer/alsa_mixer.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index f3213c4cf..95e5c70ee 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -36,16 +36,19 @@ struct alsa_mixer {
};
static struct mixer_data *
-alsa_mixer_init(void)
+alsa_mixer_init(const struct config_param *param)
{
struct alsa_mixer *am = g_malloc(sizeof(struct alsa_mixer));
- am->device = NULL;
- am->control = NULL;
+
+ am->device = config_dup_block_string(param, "mixer_device", NULL);
+ am->control = config_dup_block_string(param, "mixer_control", NULL);
+
am->handle = NULL;
am->elem = NULL;
am->volume_min = 0;
am->volume_max = 0;
am->volume_set = -1;
+
return (struct mixer_data *)am;
}
@@ -60,25 +63,6 @@ alsa_mixer_finish(struct mixer_data *data)
}
static void
-alsa_mixer_configure(struct mixer_data *data, const struct config_param *param)
-{
- struct alsa_mixer *am = (struct alsa_mixer *)data;
- const char *value;
-
- value = config_get_block_string(param, "mixer_device", NULL);
- if (value != NULL) {
- g_free(am->device);
- am->device = g_strdup(value);
- }
-
- value = config_get_block_string(param, "mixer_control", NULL);
- if (value != NULL) {
- g_free(am->control);
- am->control = g_strdup(value);
- }
-}
-
-static void
alsa_mixer_close(struct mixer_data *data)
{
struct alsa_mixer *am = (struct alsa_mixer *)data;
@@ -235,7 +219,6 @@ alsa_mixer_control(struct mixer_data *data, int cmd, void *arg)
const struct mixer_plugin alsa_mixer = {
.init = alsa_mixer_init,
.finish = alsa_mixer_finish,
- .configure = alsa_mixer_configure,
.open = alsa_mixer_open,
.control = alsa_mixer_control,
.close = alsa_mixer_close