How to identify Alsa eLements?

Takashi Sakamoto o-takashi at sakamocchi.jp
Fri Jul 3 10:53:34 CEST 2020


On Fri, Jul 03, 2020 at 08:16:26AM +0200, Tanjeff Moos wrote:
> > 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.
 
So do I. I can imagine that the toughness of work to design good
abstraction for the control feature...

> 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?
 
Yes, as long as I know.

HCTL abstraction nearly equals to 'CTL + cache mechanism for control elements +
event notification callback'. However in some cases of addition/removal control
element set from user space[1], it hits assert and aborts programs with
panic.

SCTL/MIXER/MIXER_SELEM features includes extra filter logic for control
elements with the configuration. They're specialized to usual channel of
audio; e.g. stereo, surround sounds. It's functional as long as using usual
sound devices such as stereo speakers. On the other hand, they can handle
just a part of the channels when handling control elements for exceptional
multi-channel of audio for recording equipments. I guess that your case
is the latter.

> > 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!

Quashctl is pretty good tool for the purpose as long as I know. I wish for
someone to develop similar functional tool with CUI or TUI...


[1] for example, below test program can abort pulseaudio when removing
added control element set:
https://github.com/alsa-project/alsa-lib/blob/master/test/user-ctl-element-set.c


Regards

Takashi Sakamoto


More information about the Alsa-devel mailing list