Re: [linux-audio-dev] snd_pcm_poll_descriptors_revents() question

From: Fons Adriaensen <fons.adriaensen@email-addr-hidden>
Date: Wed Nov 08 2006 - 20:47:51 EET

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.
Received on Thu Nov 9 00:15:01 2006

This archive was generated by hypermail 2.1.8 : Mon Nov 13 2006 - 12:19:29 EET