From 331b714a7a74b26a99fe46add9443a339e44fb02 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Mar 2009 19:49:26 +0100 Subject: alsa_mixer: pass default device to config_get_block_string() Instead of replacing NULL with the default device in the open() method, pass the default device to config_get_block_string(). --- src/mixer/alsa_mixer.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c index 62f501110..9609a837b 100644 --- a/src/mixer/alsa_mixer.c +++ b/src/mixer/alsa_mixer.c @@ -47,8 +47,10 @@ alsa_mixer_init(const struct config_param *param) mixer_init(&am->base, &alsa_mixer); - am->device = config_get_block_string(param, "mixer_device", NULL); - am->control = config_get_block_string(param, "mixer_control", NULL); + am->device = config_get_block_string(param, "mixer_device", + VOLUME_MIXER_ALSA_DEFAULT); + am->control = config_get_block_string(param, "mixer_control", + VOLUME_MIXER_ALSA_CONTROL_DEFAULT); am->handle = NULL; am->elem = NULL; @@ -81,12 +83,7 @@ alsa_mixer_open(struct mixer *data) struct alsa_mixer *am = (struct alsa_mixer *)data; int err; snd_mixer_elem_t *elem; - const char *control_name = VOLUME_MIXER_ALSA_CONTROL_DEFAULT; - const char *device = VOLUME_MIXER_ALSA_DEFAULT; - if (am->device) { - device = am->device; - } err = snd_mixer_open(&am->handle, 0); snd_config_update_free_global(); if (err < 0) { @@ -94,7 +91,7 @@ alsa_mixer_open(struct mixer *data) return false; } - if ((err = snd_mixer_attach(am->handle, device)) < 0) { + if ((err = snd_mixer_attach(am->handle, am->device)) < 0) { g_warning("problems attaching alsa mixer: %s\n", snd_strerror(err)); alsa_mixer_close(data); @@ -118,13 +115,9 @@ alsa_mixer_open(struct mixer *data) elem = snd_mixer_first_elem(am->handle); - if (am->control) { - control_name = am->control; - } - while (elem) { if (snd_mixer_elem_get_type(elem) == SND_MIXER_ELEM_SIMPLE) { - if (strcasecmp(control_name, + if (strcasecmp(am->control, snd_mixer_selem_get_name(elem)) == 0) { break; } @@ -140,7 +133,7 @@ alsa_mixer_open(struct mixer *data) return true; } - g_warning("can't find alsa mixer control \"%s\"\n", control_name); + g_warning("can't find alsa mixer control \"%s\"\n", am->control); alsa_mixer_close(data); return false; -- cgit v1.2.3