[linux-audio-dev] snd_pcm_poll_descriptors_revents() question

Fons Adriaensen fons.adriaensen at skynet.be
Wed Nov 8 18:47:51 UTC 2006


On Wed, Nov 08, 2006 at 05:58:40PM +0100, Clemens Ladisch wrote:

> > In that case, how can one test if *all* pollfd for a given
> > pcm are ready ?
> 
> You cannot.  The state of the file descriptors is not necessarily
> related to the state of the PCM device (which is why this function
> exists).

OK, thanks. 

So a loop waiting for both capture and playback being ready
could be something like (cut down to the bare minimum):


    n_play = driver->play_parm.npoll;
    n_capt = driver->capt_parm.npoll;
    while (n_play || n_capt)
    {
        if (n_play) snd_pcm_poll_descriptors (driver->play_parm.handle, pfd, n_play);
	if (n_capt) snd_pcm_poll_descriptors (driver->capt_parm.handle, pfd + n_play, n_capt);
	prv = poll (pfd, n_play + n_capt, 1000);
        if (prv < 0)
        {
            if (errno == EINTR) return ERR1;
	    return ERR2;
	}
        if (prv == 0) return ERR3;
        if (n_play)
	{
	    snd_pcm_poll_descriptors_revents (driver->play_parm.handle, pfd, n_play, &rev);
            if (rev & POLLERR) return ERR4;
            if (rev & POLLOUT) n_play = 0;
	}
        if (n_capt)
	{
	    snd_pcm_poll_descriptors_revents (driver->capt_parm.handle, pfd + n_play, n_capt, &rev);
            if (rev & POLLERR) return ERR5;
            if (rev & POLLIN) n_capt = 0;
	}
    }
    return 0;
    

-- 
FA

Lascia la spina, cogli la rosa.




More information about the Linux-audio-dev mailing list