[alsa-devel] calling snd_ctl_notify from mixer ctl_put

Ondrej Zary linux at rainbow-software.org
Thu Oct 11 21:29:02 CEST 2012

I want to enable/disable some mixer controls based on state of another control 
(switching between limiter and AGC mode). So I (re)set the 
SNDRV_CTL_ELEM_ACCESS_INACTIVE flag in kctl->vd[0].access
and then call snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id);
Everyting from ctl_put() mixer callback.

When changing the control value in alsamixer, it crashes with:
alsamixer: simple.c:948: snd_mixer_selem_get_enum_item: Assertion 
`(elem)->type == SND_MIXER_ELEM_SIMPLE' failed.

When the snd_ctl_notify() call is commented-out, it does not crash.

There is snd_ctl_activate_id() function in sound/core/control.c (not used by 
any driver, btw.) which does the same, protected by card->controls_rwsem. 
However, it locks up on that semaphore when called from the mixer callback.

Oxygen/Xonar WM8776 driver is doing the same thing - I wonder if I'm doing 
something wrong or if that driver crashes alsamixer too?

Is there any way to do this properly?

Ondrej Zary

More information about the Alsa-devel mailing list