aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/asoundlib.h3
-rw-r--r--mixer.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index 3d20b94..873b9c9 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -215,6 +215,9 @@ const char *mixer_get_name(struct mixer *mixer);
unsigned int mixer_get_num_ctls(struct mixer *mixer);
struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id);
struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name);
+struct mixer_ctl *mixer_get_ctl_by_name_and_index(struct mixer *mixer,
+ const char *name,
+ unsigned int index);
/* Get info about mixer controls */
const char *mixer_ctl_get_name(struct mixer_ctl *ctl);
diff --git a/mixer.c b/mixer.c
index 4568cca..afe9d7f 100644
--- a/mixer.c
+++ b/mixer.c
@@ -192,6 +192,13 @@ struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id)
struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
{
+ return mixer_get_ctl_by_name_and_index(mixer, name, 0);
+}
+
+struct mixer_ctl *mixer_get_ctl_by_name_and_index(struct mixer *mixer,
+ const char *name,
+ unsigned int index)
+{
unsigned int n;
if (!mixer)
@@ -199,7 +206,8 @@ struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
for (n = 0; n < mixer->count; n++)
if (!strcmp(name, (char*) mixer->elem_info[n].id.name))
- return mixer->ctl + n;
+ if (index-- == 0)
+ return mixer->ctl + n;
return NULL;
}