summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-02-17 16:58:12 +0100
committerTakashi Iwai <tiwai@suse.de>2009-02-17 16:58:12 +0100
commit81241ffb8176bde284699e5839bb944db39c773c (patch)
treeaf421f07fea428f68e0a3e30a31a92f6e4f2a545
parente38f921625a13a5367f34c343893aa8f2d15efe4 (diff)
downloadalsa-lib-81241ffb8176bde284699e5839bb944db39c773c.tar.gz
Change numid properly with external ctl plugins
So far, external ctl plugins don't change numid. Some apps expect the non-zero numids with list, and the plugin doesn't work for them. This patch adds a fake numid to each control based on the offset number. The lookup with non-zero numid is supported but is pretty inefficient. Eventually the plugin side may be optimized to look at the numid, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--src/control/control_ext.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/control/control_ext.c b/src/control/control_ext.c
index a8675c13..d1fe8eaa 100644
--- a/src/control/control_ext.c
+++ b/src/control/control_ext.c
@@ -107,6 +107,7 @@ static int snd_ctl_ext_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
ret = ext->callback->elem_list(ext, offset, ids);
if (ret < 0)
return ret;
+ ids->numid = offset + 1; /* fake number */
list->used++;
offset++;
ids++;
@@ -114,13 +115,24 @@ static int snd_ctl_ext_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
return 0;
}
+static snd_ctl_ext_key_t get_elem(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id)
+{
+ int numid = id->numid;
+ if (numid > 0) {
+ ext->callback->elem_list(ext, numid - 1, id);
+ id->numid = numid;
+ } else
+ id->numid = 0;
+ return ext->callback->find_elem(ext, id);
+}
+
static int snd_ctl_ext_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
{
snd_ctl_ext_t *ext = handle->private_data;
snd_ctl_ext_key_t key;
int type, ret;
- key = ext->callback->find_elem(ext, &info->id);
+ key = get_elem(ext, &info->id);
if (key == SND_CTL_EXT_KEY_NOT_FOUND)
return -ENOENT;
ret = ext->callback->get_attribute(ext, key, &type, &info->access, &info->count);
@@ -200,7 +212,7 @@ static int snd_ctl_ext_elem_read(snd_ctl_t *handle, snd_ctl_elem_value_t *contro
int type, ret;
unsigned int access, count;
- key = ext->callback->find_elem(ext, &control->id);
+ key = get_elem(ext, &control->id);
if (key == SND_CTL_EXT_KEY_NOT_FOUND)
return -ENOENT;
ret = ext->callback->get_attribute(ext, key, &type, &access, &count);
@@ -254,7 +266,7 @@ static int snd_ctl_ext_elem_write(snd_ctl_t *handle, snd_ctl_elem_value_t *contr
int type, ret;
unsigned int access, count;
- key = ext->callback->find_elem(ext, &control->id);
+ key = get_elem(ext, &control->id);
if (key == SND_CTL_EXT_KEY_NOT_FOUND)
return -ENOENT;
ret = ext->callback->get_attribute(ext, key, &type, &access, &count);