aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2016-09-16 09:22:51 -0400
committerTaylor Holberton <taylorcholberton@gmail.com>2016-09-16 09:22:51 -0400
commit2087ef2b624cc2ab6c53628d0f03b317f1cb1bcf (patch)
tree03a6a6ebd9e977cdbcb98f0d4b59f944a9ad3e94
parent713e656a07d7530a2036e3af2972c6da226fb684 (diff)
parent7687f0fa2a222c4793de93fb4eeb70323b1603ed (diff)
Merge branch 'dawagner-address-duplicate-control-names'
-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 d87e357..8c215ce 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -232,6 +232,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 */
unsigned int mixer_ctl_get_id(struct mixer_ctl *ctl);
diff --git a/mixer.c b/mixer.c
index d6f3fcd..ac294ca 100644
--- a/mixer.c
+++ b/mixer.c
@@ -189,6 +189,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;
struct mixer_ctl *ctl;
@@ -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*) ctl[n].info.id.name))
- return &ctl[n];
+ if (index-- == 0)
+ return mixer->ctl + n;
return NULL;
}