diff options
author | Max Kellermann <max@duempel.org> | 2009-03-26 19:49:26 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-26 19:49:26 +0100 |
commit | 331b714a7a74b26a99fe46add9443a339e44fb02 (patch) | |
tree | 563dd45725c8918f6545d83c14a350a655fd7f79 /src | |
parent | f06f049cd8f9f5d0458e9dc7ebe72d8dfbc95d10 (diff) | |
download | mpd-331b714a7a74b26a99fe46add9443a339e44fb02.tar.gz mpd-331b714a7a74b26a99fe46add9443a339e44fb02.tar.xz mpd-331b714a7a74b26a99fe46add9443a339e44fb02.zip |
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().
Diffstat (limited to '')
-rw-r--r-- | src/mixer/alsa_mixer.c | 21 |
1 files changed, 7 insertions, 14 deletions
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; |