Hi Takashi Sakamoto,
On 03/07/2020 02:34, Takashi Sakamoto wrote:
Hi,
On Thu, Jul 02, 2020 at 10:05:01PM +0200, Tanjeff Moos wrote:
[...]
My questions:
- Are name and index enough to identify an element?
In ALSA control core, 'snd_ctl_find_id()' helper function[1] is used to find control element set by the given information from userspace application. You can see the algorithm supports two cases:
- numid matching
- the combination matching with:
- iface
- device
- subdevice
- name
- index is within the range of set
As you know, the numid is not constant between every bootup since it's assigned dynamically (see __snd_ctl_add_replace() helper function[2]). Thus the way 2 is available in the case to hard-code in userspace application.
Thanks for the clarification.
- How can I obtain the index? The name and numid are shown by 'amixer contents', for example.
[...]
Anyway, when using alsa-lib application for the purpose, you should pay enough attention to which API is used since alsa-lib includes several abstractions of API for control element set in each level:
- Lower abstraction (snd_ctl_xxx)
- Higher abstraction (snd_hctl_xxx)
- Setup control interface (snd_sctl_xxx)
- Mixer interface (snd_mixer_xxx)
- Simple Mixer interface (snd_mixer_selem_xxx)
I find this quite confusing. If I could change a volume control using any of those interfaces, then I don't understand when to use which interface. I'm sure that there is good reasoning for each of them, but unfortunatly the documentation has very little information about these concepts.
Anyway, I will stick to the lower abstraction which serves my needs. In the worst case I will do more work than necessary ;-)
The configuration space of alsa-lib affects Setup control interface and Mixer interface. On the other hand, it doesn't affect the lower/higher abstraction. The amixer is a kind of application to use 'snd_hctl_xxx', 'snd_mixer_xxx', and 'snd_mixer_selem_xxx'.
So the controls offered by CTL/HCTL are determined by the driver? And SCTL, MIXER and MIXER_SELEM are influenced by user space config files?
When you'd like to communicate to kernel land implementation without any effects of alsa-lib's configuration space. it's better to use the lower/higher abstractions. As long as I've used, 'qashctl' in QasTools[4] is good GUI application for this purpose. It's written with Qt5 and seems to be helpful for your work in both of GUI programming and control elements handling.
qashctl is indeed very helpful, thank you! As being said, I'll stick to CTL.
Thank you very much for your advice!
- Tanjeff