On Sat, Feb 05, 2022 at 09:29:42AM +0100, Anton Lindqvist wrote:
> Hi,
> I recently got a USB headset with physical volume buttons, handled by
> ucc(4). However, after enabling the device in sndiod the volume buttons
> does not cause the volume to change. Turns out wskbd_set_mixervolume()
> is only propagating volume changes to first attached audio device. Is
> their any good not to consider all attached audio devices?

This is a hack to make pc keyboard volume keys mimic volume keys of
old laptops, which used to simply control internal speaker/headphones
level. Hence the use of the first device (in most cases the internal).

> The diff below gives me the desired behavior by propagating volume
> changes to all attached audio devices.
> 

Your diff is correct.

However it's based on a broken hack, so it won't work as expected:
Currently volume keys change the volume but also propagate to X as
XF86XK_Audio{Raise,Lower}Volume events which in turn may change the
volume a second time in a different way, possibly of different
device. To increase further the confusion, X keys auto-repeat, while
volume key changes through wskbd_set_mixervolume() don't.

For instance, in one terminal start "sndioctl -m" to monitor volume
changes then play something with ports/mplayer and observe volume
changes:

$ sndioctl -m 
...
output[0].level=0.322   # changed
output[1].level=0.322   # changed
app/mplayer0.level=0.567        # changed
output[0].level=0.353   # changed
output[1].level=0.353   # changed
app/mplayer0.level=0.583        # changed

IMHO, adding a sysctl or wsconsctl knob, as kettenis@ suggested, would
make your keys "work", and allow to start experimenting with proper
user-space solution.

Reply via email to