From: Takashi Iwai <tiwai@suse.de>
To: Paul Davis <paul@linuxaudiosystems.com>
Cc: Josh Haberman <joshua@haberman.com>,
jackit-devel@lists.sourceforge.net,
alsa-devel@lists.sourceforge.net
Subject: Re: Re: [Jackit-devel] alsa_driver_wait -> libasound?
Date: Tue, 14 Jan 2003 18:03:06 +0100 [thread overview]
Message-ID: <s5hbs2jy88l.wl@alsa2.suse.de> (raw)
In-Reply-To: <200301141647.h0EGldCg019400@spider.tela.com>
At Tue, 14 Jan 2003 11:47:58 -0500,
Paul Davis wrote:
>
> >> 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;
> >}
>
> this isn't even close. the function in question waits until each and
> every handle is ready. that means reentering poll over and over again
> until each handle is ready, making sure to only poll on the handles
> that are not yet ready (because otherwise poll returns immediately).
>
> the semantics are not "wait for any one many", its "wait for all or an
> error".
ah, now got the meaning. so, something like that...
// set up pfds...
...
for (;;) {
err = poll(pfds, num_handles, timeout);
if (err < 0)
return -errno;
else if (err == 0)
return 0;
i = 0;
while (i < num_handles) {
if (pfds[i].revents & POLLOUT) {
num_handles--;
memmove(pfds + i + 1, pfds + i,
sizeof(*pfds) * (num_handles - i));
} else
i++;
}
}
return 1;
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
next prev parent reply other threads:[~2003-01-14 17:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1042530370.10960.111.camel@birdie>
2003-01-14 14:38 ` [Jackit-devel] alsa_driver_wait -> libasound? Paul Davis
2003-01-14 16:31 ` Jaroslav Kysela
2003-01-14 16:42 ` Paul Davis
2003-01-14 19:35 ` Jaroslav Kysela
2003-01-14 20:23 ` Paul Davis
2003-01-16 0:14 ` Josh Haberman
2003-01-14 18:55 ` Josh Haberman
2003-01-14 19:25 ` Jaroslav Kysela
2003-01-14 16:32 ` Takashi Iwai
2003-01-14 16:47 ` Paul Davis
2003-01-14 17:03 ` Takashi Iwai [this message]
2003-01-14 19:04 ` Josh Haberman
2003-01-14 19:20 ` Paul Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hbs2jy88l.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=jackit-devel@lists.sourceforge.net \
--cc=joshua@haberman.com \
--cc=paul@linuxaudiosystems.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox