[LAD] Alsa: poll mixer events, always returns true in subsequent calls

Clemens Ladisch clemens at ladisch.de
Tue Jan 29 08:39:31 UTC 2013

Muffinman wrote:
> I'm trying to poll mixer events in Alsa using C. I've used the following
> functions within an infinite while loop:
> ...
> snd_hctl_poll_descriptors(hctl, poll_fds, 1);

You are supposed to call snd_hctl_poll_descriptors_count() to get the
number of descriptors.

> if (poll_fds[0].revents & POLLIN)

You are supposed to call snd_hctl_poll_descriptors_revents() to get the
events from the descriptors.

> While I can get the first mixer event fine, in all subsequent rounds,
> both snd_hctl_wait and poll always return immediately.

You should call snd_hctl_handle_events() to read all the events.

> However, calling snd_hctl_handle_events here never returns
> and I can't quite figure out why.

See amixer/amixer.c in the alsa-utils package for an example.

"amixer events" is undocumented for some reason; but does it work?


More information about the Linux-audio-dev mailing list