[alsa-devel] alsactl adds volume controls?

Clemens Ladisch clemens at ladisch.de
Thu Sep 30 13:03:52 CEST 2010

Colin Guthrie wrote:
>  1. *All* HDA devices have a PCM softvol control.

The HDA "default" and "front" devices include the softvol plugin.
However, when the control already exists as a hardware control, the
plugin removes itself and isn't actually used (same as if the
SND_PCM_NO_SOFTVOL flag is set).

So, all HDA devices have a "PCM Playback Volume" control, either in
hardware or created by the softvol plugin.  (This control is absent
only when the softvol plugin has not been used.)

> Some use this actively due to the fact they lack a real h/w volume
> control. Others do not technically "use" it.

The hardware control is always used.  The user control created by
softvol is used when some application is using the softvol plugin.
(For an application using device names like "hw" or "plughw", there will
be not softvol plugin.)

>  2. The PCM softvol has a 51dB range. When it's "active" this presumably
> works. When it's inactive (which appears to be the case on my primary
> machine), regardless of what the it's set to, there will be 0dB change.

Yes.  (When using ALSA's default "default" or "front" devices, it should
be active.)

>  3. There is a flag when opening PCM device (SND_PCM_NO_SOFTVOL) that
> will cause the PCM mixer to not have any impact in *all* cases

... except when that control is a hardware control.

>  4. When looking at only mixer elements (e.g. not opening any streams)
> there is no way to know whether a given mixer is active or not (with
> current APIs), i.e. From using only the mixer related API calls, the PCM
> volume range is always presented as being 0 -> -51dB for the PCM
> softvol, even when it actually has no effect (i.e. the information
> presented is highly misleading).  Is there a way to know which mixers
> are active when you open a pcm stream? (and this question applies to
> both with and without using the SND_PCM_NO_SOFTVOL flag).

There is snd_ctl_elem_info_is_inactive(), but the softvol plugin never
sets its control to inactive.

Since there is only one global control, any property of this control is
not useful for applications like PA to determine whether its own stream
is being affected.

> Potential solutions would include:
>  1. If the "correct" solution is to just use SND_PCM_NO_AUTO in PA, and
> then deliberately/actively ignore any softvol mixers, then nothing needs
> done at the alsa level I guess.


Use snd_ctl_elem_info_is_user() to check for the softvol mixer element.

>  2. Simply fixing things to NOT add the inactive PCM mixer when it's not
> needed.

It was decided to store this control in the hardware device so that it
is saved/restored together with the 'real' controls.


More information about the Alsa-devel mailing list