aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2009-04-28 09:15:48 +0200
committerMax Kellermann <max@duempel.org>2009-04-28 09:15:48 +0200
commit05dfdfdb398146f3427be154bfe599fac61ed025 (patch)
treed0f115cd57594d2f0c6a29119e267f0d14b542a5 /src
parent70d322b296247cd6d09de894f6d1cb06f5cf0d11 (diff)
downloadmpd-05dfdfdb398146f3427be154bfe599fac61ed025.tar.gz
mpd-05dfdfdb398146f3427be154bfe599fac61ed025.tar.xz
mpd-05dfdfdb398146f3427be154bfe599fac61ed025.zip
alsa_mixer: add mixer_index option
This allows you to select controls with duplicate names.
Diffstat (limited to 'src')
-rw-r--r--src/mixer/alsa_mixer.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mixer/alsa_mixer.c b/src/mixer/alsa_mixer.c
index fb0834338..52f30b6f4 100644
--- a/src/mixer/alsa_mixer.c
+++ b/src/mixer/alsa_mixer.c
@@ -25,6 +25,7 @@
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
+#define VOLUME_MIXER_ALSA_INDEX_DEFAULT 0
struct alsa_mixer {
/** the base mixer class */
@@ -32,6 +33,7 @@ struct alsa_mixer {
const char *device;
const char *control;
+ unsigned int index;
snd_mixer_t *handle;
snd_mixer_elem_t *elem;
@@ -51,6 +53,8 @@ alsa_mixer_init(const struct config_param *param)
VOLUME_MIXER_ALSA_DEFAULT);
am->control = config_get_block_string(param, "mixer_control",
VOLUME_MIXER_ALSA_CONTROL_DEFAULT);
+ am->index = config_get_block_unsigned(param, "mixer_index",
+ VOLUME_MIXER_ALSA_INDEX_DEFAULT);
return &am->base;
}
@@ -117,8 +121,9 @@ alsa_mixer_open(struct mixer *data)
while (elem) {
if (snd_mixer_elem_get_type(elem) == SND_MIXER_ELEM_SIMPLE) {
- if (strcasecmp(am->control,
- snd_mixer_selem_get_name(elem)) == 0) {
+ if ((strcasecmp(am->control,
+ snd_mixer_selem_get_name(elem)) == 0) &&
+ (am->index == snd_mixer_selem_get_index(elem))) {
break;
}
}