[alsa-devel] Confusion about whether snd_pcm_poll_descriptors_revents()'s revents field is a single integer or an array

Takashi Iwai tiwai at suse.de
Mon Feb 2 15:34:57 CET 2009

At Mon, 02 Feb 2009 08:02:29 +0100,
I wrote:
> At Mon, 2 Feb 2009 03:50:22 +0100,
> Lennart Poettering wrote:
> > 
> > Heya!
> > 
> > If we look into the pcm example how snd_pcm_poll_descriptors_revents()
> > is used then we can see that the revents parameter apparently is
> > supposed to be a single integer. (which makes a lot of sense to me)
> > 
> > http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html#a33
> > 
> > However, snd_pcm_wait_nocheck() calls the same function and assumes it
> > is a complete array!
> > 
> > http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm.c;h=74d1d1a4bd6083cd461b6d793c0ae41cca912f16;hb=HEAD#l2368
> > 
> > So what's it now? It makes more sense to me if it would be a single
> > fd. 
> No, it's a bug in test/pcm.c.  As documented, the API converts (fixes)
> each poll_fd in the given array.

Hmm..  just looking through the whole tree again, this thing seems
mixed up weirdly right now.
At least, the latest pcm_hw.c assumes the single revent.  Meanwhile,
the old pcm_multi.c assumed the multiple revents.

As you notice the work "revents", the function itself supposes the
multiple events.   However, obviously, handling the single revent is
much easier for applications. 

So I believe we should go to the current pcm_hw.c implementation way,
i.e. demangling to a single revent.  But, yes, more investigations and
fixes are needed.


More information about the Alsa-devel mailing list