From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Re: [Jackit-devel] alsa_driver_wait -> libasound? Date: Tue, 14 Jan 2003 17:32:45 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <1042530370.10960.111.camel@birdie> <200301141438.h0EEcWFH028649@spider.tela.com> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <200301141438.h0EEcWFH028649@spider.tela.com> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Paul Davis Cc: Josh Haberman , jackit-devel@lists.sourceforge.net, alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 14 Jan 2003 09:38:51 -0500, Paul Davis wrote: > > > [ cc'ed to alsa-devel ] > > >I think I've asked something to this effect before, but is there any > >reason why the polling portion of alsa_driver_wait should not be in > >libasound? It's a very complicated piece of code that performs an > >operation that many programs are likely to want. What if it was written > >as a companion function to snd_pcm_wait(): > > > > int snd_pcm_wait_many( snd_pcm_t **handles, int num_handles, > > int timeout); > > > >...not that JACK would have to give up its version with extra error > >reporting and timing, but for programs with simpler needs it would be a > >lot nicer than having to set and test all those poll conditions for all > >of the pfds on all the handles. > > > >I should probably ask this on the ALSA list, but I'm more familiar with > >the people here. Any reason why this couldn't go into libasound? > > seems like a good idea to me, although there is a small problem. the > current snd_pcm_wait function waits till the handles is > readable/writable, whereas the JACK code waits till the handles all > have a certain minimum amount of data/space. this is a subtle but > rather important difference. i thought that snd_pcm_wait() waits until data/space of swparams->avail_min become available, too? > > that said, i think it would be great if this found its way into libasound. is the below code ok? int snd_pcm_wait_many(snd_pcm_t **handles, int num_handles, int timeout) { struct pollfd *pfds; int i, err; pfds = (struct pollfd *)alloca(sizeof(*pfds) * num_handles); if (! pfds) reutrn -ENOMEM; for (i = 0; i < num_handles; i++) { err = snd_pcm_poll_descriptors(handles[i], &pfds[i], 1); assert(err == 1); } err = poll(pfds, num_handles, timeout); if (err < 0) return -errno; return err > 0 ? 1 : 0; } Takashi ------------------------------------------------------- This SF.NET email is sponsored by: FREE SSL Guide from Thawte are you planning your Web Server Security? Click here to get a FREE Thawte SSL guide and find the answers to all your SSL security issues. http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en