All of lore.kernel.org
 help / color / mirror / Atom feed
* standard read/write vs event waiting routines (poll) in ALSA
@ 2019-07-31 16:05 Diego Buffa
  2019-07-31 17:03 ` Jaroslav Kysela
  0 siblings, 1 reply; 3+ messages in thread
From: Diego Buffa @ 2019-07-31 16:05 UTC (permalink / raw)
  To: alsa-devel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: standard read/write vs event waiting routines (poll) in ALSA
  2019-07-31 16:05 standard read/write vs event waiting routines (poll) in ALSA Diego Buffa
@ 2019-07-31 17:03 ` Jaroslav Kysela
  2019-08-01  9:04   ` Diego Buffa
  0 siblings, 1 reply; 3+ messages in thread
From: Jaroslav Kysela @ 2019-07-31 17:03 UTC (permalink / raw)
  To: Diego Buffa, alsa-devel

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@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: standard read/write vs event waiting routines (poll) in ALSA
  2019-07-31 17:03 ` Jaroslav Kysela
@ 2019-08-01  9:04   ` Diego Buffa
  0 siblings, 0 replies; 3+ messages in thread
From: Diego Buffa @ 2019-08-01  9:04 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: alsa-devel

Hi Jaroslav,
many thanks for your answer, if I understand correctly pcmjob.c, you are
polling on capture, play and ctrl files (thread_job1).
So in this case it is clear the scope of the polling, sorry I just look at
https://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html and
I was not understanding the advantage of using poll.

Regards,
d.

On Wed, Jul 31, 2019 at 7:03 PM Jaroslav Kysela <perex@perex.cz> wrote:

> 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@perex.cz>
> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-01  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 16:05 standard read/write vs event waiting routines (poll) in ALSA Diego Buffa
2019-07-31 17:03 ` Jaroslav Kysela
2019-08-01  9:04   ` Diego Buffa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.