[alsa-devel] Some questions about userspace control elements

Takashi Sakamoto o-takashi at sakamocchi.jp
Thu Feb 5 00:51:17 CET 2015


Hi Clemens,

I find a curious issue about the userspace element. Could I ask you to
give some comments about

The code is this one line.

sound/core/control.c:1188
{{{
kctl.count = info->owner ? info->owner : 1;
}}}
http://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/core/control.c?id=6ccd93bdb989507717edb375d40534f1177822c5#n1188

In this code, the value in struct snd_ctl_elem_info.owner is assigned to
struct snd_kcontrol.count. The meaning of these two member is completely
different but assigned.

include/sound/control.h:67
{{{
struct snd_kcontrol {
...
unsigned int count;
...
};
}}}
http://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/include/sound/control.h?id=6ccd93bdb989507717edb375d40534f1177822c5#n67

include/uapi/sound/asound.h:851
{{{
struct snd_ctl_elem_info {
...
__kernel_pid_t owner;		/* owner's PID of this control */
...
};
};
}}}
http://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/include/uapi/sound/asound.h?id=6ccd93bdb989507717edb375d40534f1177822c5#n851
(I wonder why the value with _kernel_pid type is exported to userspace...)

I guess that the reason is to limit the number of event generated when
the control element set is operated. Actually, my sample code reports
one event every time when operating the control element with 10 entries.
But I believe this is the different behaviour as the kernel control
elements do.

sound/core/control.c:257
{{{
kctl.count = ncontrol->count ? ncontrol->count : 1;
}}}
http://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/core/control.c?id=6ccd93bdb989507717edb375d40534f1177822c5#n257

For me, the behaviour of userspace control element is a bit strange. The
behaviour is legal as a control element?


Regards

Takashi Sakamoto



More information about the Alsa-devel mailing list