summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-06-29 22:43:01 +0900
committerTakashi Iwai <tiwai@suse.de>2016-06-30 08:42:17 +0200
commit1edc5f5259f36a17487f0955401049369d71dc7d (patch)
tree4c6c0b3c69a3b9f6bc042db9d31e77af03483f24
parent16812b70daeb1c31f4681d22474b21f986ff6619 (diff)
downloadalsa-lib-1edc5f5259f36a17487f0955401049369d71dc7d.tar.gz
ctl: optimize a test for user-defined element set to older kernels
In Linux 4.0 or former, call of ioctl(2) with SNDRV_CTL_IOCTL_ELEM_ADD doesn't fill all of identical information in an argument; i.e. numid. With the kernel, a test of user-defined element set fails. This commit fixes the bug. The 'numid' field in identical information is always zero when adding an element set, therefore zero check has an effect. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--test/user-ctl-element-set.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/test/user-ctl-element-set.c b/test/user-ctl-element-set.c
index 09c79291..bfb11d7f 100644
--- a/test/user-ctl-element-set.c
+++ b/test/user-ctl-element-set.c
@@ -279,6 +279,7 @@ static int check_elem_set_props(struct elem_set_trial *trial)
snd_ctl_elem_id_t *id;
snd_ctl_elem_info_t *info;
unsigned int numid;
+ unsigned int index;
unsigned int i;
int err;
@@ -286,10 +287,18 @@ static int check_elem_set_props(struct elem_set_trial *trial)
snd_ctl_elem_info_alloca(&info);
snd_ctl_elem_info_set_id(info, trial->id);
- numid = snd_ctl_elem_info_get_numid(info);
+ numid = snd_ctl_elem_id_get_numid(trial->id);
+ index = snd_ctl_elem_id_get_index(trial->id);
for (i = 0; i < trial->element_count; ++i) {
- snd_ctl_elem_info_set_numid(info, numid + i);
+ snd_ctl_elem_info_set_index(info, index + i);
+
+ /*
+ * In Linux 4.0 or former, ioctl(SNDRV_CTL_IOCTL_ELEM_ADD)
+ * doesn't fill all of fields for identification.
+ */
+ if (numid > 0)
+ snd_ctl_elem_info_set_numid(info, numid + i);
err = snd_ctl_elem_info(trial->handle, info);
if (err < 0)
@@ -335,25 +344,25 @@ static int check_elems(struct elem_set_trial *trial)
{
snd_ctl_elem_value_t *data;
unsigned int numid;
+ unsigned int index;
unsigned int i;
int err;
snd_ctl_elem_value_alloca(&data);
snd_ctl_elem_value_set_id(data, trial->id);
-
- /*
- * Get the value of numid field in identical information for the first
- * element of this element set.
- */
- numid = snd_ctl_elem_value_get_numid(data);
+ numid = snd_ctl_elem_id_get_numid(trial->id);
+ index = snd_ctl_elem_id_get_index(trial->id);
for (i = 0; i < trial->element_count; ++i) {
+ snd_ctl_elem_value_set_index(data, index + i);
+
/*
- * Here, I increment numid, while we can also increment offset
- * to enumerate each element in this element set.
+ * In Linux 4.0 or former, ioctl(SNDRV_CTL_IOCTL_ELEM_ADD)
+ * doesn't fill all of fields for identification.
*/
- snd_ctl_elem_value_set_numid(data, numid + i);
+ if (numid > 0)
+ snd_ctl_elem_value_set_numid(data, numid + i);
err = snd_ctl_elem_read(trial->handle, data);
if (err < 0)