mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
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>
This commit is contained in:
parent
16812b70da
commit
1edc5f5259
1 changed files with 20 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue