[alsa-devel] standard read/write vs event waiting routines (poll) in ALSA

Diego Buffa diego.buffa at gmail.com
Wed Jul 31 18:05:40 CEST 2019


Hi all,
I am trying to learn more about ALSA, I always used example found in the
howtos but now I would go further.

I went though ALSA documentation (
https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html) and in the
specific the transfer methods.
Basically I don't understand the advantages of using poll instead of
traditional blocking read/write.

Generally I know that using poll I can multiplex I/O on several files, but
in ALSA I cannot create the poll descriptor array as I want, as I must use
snd_pcm_poll_descriptors() which requires that the poll descriptor array
should have the size returned by snd_pcm_poll_descriptors_count().

Am I supposed to realloc the poll array descriptor once I set it up with
ALSA, and add my own files? Should I then always check poll array
descriptor with snd_pcm_poll_descriptors_revents() before checking my own
files? And in this case it is safe to call
snd_pcm_poll_descriptors_revents() with a  poll array descriptor bigger
than the size returned by snd_pcm_poll_descriptors_count()?

Many thanks in advance.


More information about the Alsa-devel mailing list