Re: standard read/write vs event waiting routines (poll) in ALSA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dne 31. 07. 19 v 18:05 Diego Buffa napsal(a):
> 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.

All ALSA poll functions works only with the ALSA file descriptors. Basically,
allocate your pollfd array as big as you like and get the file descriptors
from ALSA to this array (using the returned count) and check those descriptors
through ALSA (revents function). Look to alsa-utils/alsaloop/pcmjob.c for an
example.

						Jaroslav

-- 
Jaroslav Kysela <perex@xxxxxxxx>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux