All of lore.kernel.org
 help / color / mirror / Atom feed
* problems using select() on alsa pcm.
@ 2004-03-25  3:39 James Courtier-Dutton
  2004-03-25  4:08 ` Paul Davis
  2004-03-25  9:36 ` Jaroslav Kysela
  0 siblings, 2 replies; 13+ messages in thread
From: James Courtier-Dutton @ 2004-03-25  3:39 UTC (permalink / raw)
  To: alsa-devel

open pcm, and get a handle.

snd_pcm_poll_descriptors(handle, &pfd, err);

Get a poll file scriptor in pfd.

select(nfds, rfds, wfds, efds, tvp);

Is it possible to use this call with alsa ?
It seems that the select functions as expected with the descriptor so 
that we can do a snd_pcm_writei().

It seems that the select does not function so that we can do a 
snd_pcm_readi().

Are there any documents describing how one can get the read (rfds) working?

Cheers
James



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  3:39 problems using select() on alsa pcm James Courtier-Dutton
@ 2004-03-25  4:08 ` Paul Davis
  2004-03-25  9:38   ` Jaroslav Kysela
  2004-03-25 10:25   ` Martijn Sipkema
  2004-03-25  9:36 ` Jaroslav Kysela
  1 sibling, 2 replies; 13+ messages in thread
From: Paul Davis @ 2004-03-25  4:08 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: alsa-devel

>open pcm, and get a handle.
>
>snd_pcm_poll_descriptors(handle, &pfd, err);
>
>Get a poll file scriptor in pfd.
>
>select(nfds, rfds, wfds, efds, tvp);
>
>Is it possible to use this call with alsa ?

select is generally deprecated in linux (linus says so!). but you can
use the same pfds in select as in poll (select is implemented in the
kernel using the poll code). the problem is interpreting the results
you get back (as noted recently for the dmix plugin).


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  3:39 problems using select() on alsa pcm James Courtier-Dutton
  2004-03-25  4:08 ` Paul Davis
@ 2004-03-25  9:36 ` Jaroslav Kysela
  1 sibling, 0 replies; 13+ messages in thread
From: Jaroslav Kysela @ 2004-03-25  9:36 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: alsa-devel

On Thu, 25 Mar 2004, James Courtier-Dutton wrote:

> open pcm, and get a handle.
> 
> snd_pcm_poll_descriptors(handle, &pfd, err);
> 
> Get a poll file scriptor in pfd.
> 
> select(nfds, rfds, wfds, efds, tvp);
> 
> Is it possible to use this call with alsa ?

Yes, snd_pcm_poll_descriptors() gives you all hints.
See to alsa-oss/alsa/alsa-oss.c - select() wrapper, but
man select and man poll will help you also.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  4:08 ` Paul Davis
@ 2004-03-25  9:38   ` Jaroslav Kysela
  2004-03-25 14:44     ` Paul Davis
  2004-03-25 15:13     ` James Courtier-Dutton
  2004-03-25 10:25   ` Martijn Sipkema
  1 sibling, 2 replies; 13+ messages in thread
From: Jaroslav Kysela @ 2004-03-25  9:38 UTC (permalink / raw)
  To: Paul Davis; +Cc: James Courtier-Dutton, alsa-devel

On Wed, 24 Mar 2004, Paul Davis wrote:

> >open pcm, and get a handle.
> >
> >snd_pcm_poll_descriptors(handle, &pfd, err);
> >
> >Get a poll file scriptor in pfd.
> >
> >select(nfds, rfds, wfds, efds, tvp);
> >
> >Is it possible to use this call with alsa ?
> 
> select is generally deprecated in linux (linus says so!). but you can
> use the same pfds in select as in poll (select is implemented in the
> kernel using the poll code). the problem is interpreting the results
> you get back (as noted recently for the dmix plugin).

Nope, the application must give results back to pfd array and call
snd_pcm_poll_descriptors_revents() function. In this way, everything
will work as expected.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  4:08 ` Paul Davis
  2004-03-25  9:38   ` Jaroslav Kysela
@ 2004-03-25 10:25   ` Martijn Sipkema
  2004-03-25 13:19     ` Paul Davis
  2004-03-25 14:00     ` Takashi Iwai
  1 sibling, 2 replies; 13+ messages in thread
From: Martijn Sipkema @ 2004-03-25 10:25 UTC (permalink / raw)
  To: James Courtier-Dutton, Paul Davis; +Cc: alsa-devel

> >open pcm, and get a handle.
> >
> >snd_pcm_poll_descriptors(handle, &pfd, err);
> >
> >Get a poll file scriptor in pfd.
> >
> >select(nfds, rfds, wfds, efds, tvp);
> >
> >Is it possible to use this call with alsa ?
> 
> select is generally deprecated in linux (linus says so!). but you can
> use the same pfds in select as in poll (select is implemented in the
> kernel using the poll code). the problem is interpreting the results
> you get back (as noted recently for the dmix plugin).

select and pselect do allow for a more accurate timeout specification.
Why is select deprecated?

--ms




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 10:25   ` Martijn Sipkema
@ 2004-03-25 13:19     ` Paul Davis
  2004-03-25 14:00     ` Takashi Iwai
  1 sibling, 0 replies; 13+ messages in thread
From: Paul Davis @ 2004-03-25 13:19 UTC (permalink / raw)
  To: Martijn Sipkema; +Cc: James Courtier-Dutton, alsa-devel

>> >open pcm, and get a handle.
>> >
>> >snd_pcm_poll_descriptors(handle, &pfd, err);
>> >
>> >Get a poll file scriptor in pfd.
>> >
>> >select(nfds, rfds, wfds, efds, tvp);
>> >
>> >Is it possible to use this call with alsa ?
>> 
>> select is generally deprecated in linux (linus says so!). but you can
>> use the same pfds in select as in poll (select is implemented in the
>> kernel using the poll code). the problem is interpreting the results
>> you get back (as noted recently for the dmix plugin).
>
>select and pselect do allow for a more accurate timeout specification.
>Why is select deprecated?

well, one reason might be gleaned from the man page for select_tut:

      [ ... ]

       mode  at all (see ioctl(2)). It is easy to introduce subtle errors that
       will remove the advantage of using select, hence I will present a  list
       of essentials to watch for when using the select call.
 
       1.     You should always try use select without a timeout. Your program
              should have nothing to do if there is no  data  available.  Code
              that  depends  on timeouts is not usually portable and difficult
              to debug.

of course, for main event loops in things like glib, this can't ever
really be true, but it is a rather salient point for most callers of
select(). 

i think the main reason for its "deprecation" (which is very mild,
given that its an official POSIX call) is that its semantics are not
quite as clear as poll(2). its even possible that i've missed a
retraction from linus about this.

--p


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 10:25   ` Martijn Sipkema
  2004-03-25 13:19     ` Paul Davis
@ 2004-03-25 14:00     ` Takashi Iwai
  2004-03-25 14:35       ` Martijn Sipkema
  2004-03-25 21:44       ` Glenn Maynard
  1 sibling, 2 replies; 13+ messages in thread
From: Takashi Iwai @ 2004-03-25 14:00 UTC (permalink / raw)
  To: Martijn Sipkema; +Cc: James Courtier-Dutton, Paul Davis, alsa-devel

At Thu, 25 Mar 2004 11:25:56 +0100,
Martijn Sipkema wrote:
> 
> > >open pcm, and get a handle.
> > >
> > >snd_pcm_poll_descriptors(handle, &pfd, err);
> > >
> > >Get a poll file scriptor in pfd.
> > >
> > >select(nfds, rfds, wfds, efds, tvp);
> > >
> > >Is it possible to use this call with alsa ?
> > 
> > select is generally deprecated in linux (linus says so!). but you can
> > use the same pfds in select as in poll (select is implemented in the
> > kernel using the poll code). the problem is interpreting the results
> > you get back (as noted recently for the dmix plugin).
> 
> select and pselect do allow for a more accurate timeout specification.

from the spec, yes.  but nsec resolution would be never implemented :)

> Why is select deprecated?

because select is just a wrapper of poll in fact (on linux)?


Takashi


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 14:00     ` Takashi Iwai
@ 2004-03-25 14:35       ` Martijn Sipkema
  2004-03-25 21:44       ` Glenn Maynard
  1 sibling, 0 replies; 13+ messages in thread
From: Martijn Sipkema @ 2004-03-25 14:35 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: James Courtier-Dutton, Paul Davis, alsa-devel

> > > >open pcm, and get a handle.
> > > >
> > > >snd_pcm_poll_descriptors(handle, &pfd, err);
> > > >
> > > >Get a poll file scriptor in pfd.
> > > >
> > > >select(nfds, rfds, wfds, efds, tvp);
> > > >
> > > >Is it possible to use this call with alsa ?
> > > 
> > > select is generally deprecated in linux (linus says so!). but you can
> > > use the same pfds in select as in poll (select is implemented in the
> > > kernel using the poll code). the problem is interpreting the results
> > > you get back (as noted recently for the dmix plugin).
> > 
> > select and pselect do allow for a more accurate timeout specification.
> 
> from the spec, yes.  but nsec resolution would be never implemented :)

Not nsec resolution perhaps, but a higher than msec resolution might
be useful in some cases. The fact that select was updated in the POSIX
specs to support a timespec timeout (pselect) and poll only supports
msec timeout might indicate that pselect is better suited for realtime
use. Not to mention that pselect supports at least a 31 day timeout and
that it can set the signal mask...


--ms




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  9:38   ` Jaroslav Kysela
@ 2004-03-25 14:44     ` Paul Davis
  2004-03-25 15:05       ` Jaroslav Kysela
  2004-03-25 15:13     ` James Courtier-Dutton
  1 sibling, 1 reply; 13+ messages in thread
From: Paul Davis @ 2004-03-25 14:44 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: James Courtier-Dutton, alsa-devel

>> select is generally deprecated in linux (linus says so!). but you can
>> use the same pfds in select as in poll (select is implemented in the
>> kernel using the poll code). the problem is interpreting the results
>> you get back (as noted recently for the dmix plugin).
>
>Nope, the application must give results back to pfd array and call
>snd_pcm_poll_descriptors_revents() function. In this way, everything
>will work as expected.

i thought that the flags set by select(2) were different than those
set by poll(2) ??


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 14:44     ` Paul Davis
@ 2004-03-25 15:05       ` Jaroslav Kysela
  0 siblings, 0 replies; 13+ messages in thread
From: Jaroslav Kysela @ 2004-03-25 15:05 UTC (permalink / raw)
  To: Paul Davis; +Cc: James Courtier-Dutton, alsa-devel

On Thu, 25 Mar 2004, Paul Davis wrote:

> >> select is generally deprecated in linux (linus says so!). but you can
> >> use the same pfds in select as in poll (select is implemented in the
> >> kernel using the poll code). the problem is interpreting the results
> >> you get back (as noted recently for the dmix plugin).
> >
> >Nope, the application must give results back to pfd array and call
> >snd_pcm_poll_descriptors_revents() function. In this way, everything
> >will work as expected.
> 
> i thought that the flags set by select(2) were different than those
> set by poll(2) ??

Yes, but the results are similar. So you have to do:

snd_pcm_poll_descriptors(pfds)
pfds->events -> FD_SET(x, y)
select()
FD_ISSET(x, y) -> pfds->revents
revents = snd_pcm_poll_descriptors_revents(pfds)
if (revents & POLLOUT)
  playback_event();
if (revents & POLLIN)
  capture_event();

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25  9:38   ` Jaroslav Kysela
  2004-03-25 14:44     ` Paul Davis
@ 2004-03-25 15:13     ` James Courtier-Dutton
  2004-03-25 15:38       ` Jaroslav Kysela
  1 sibling, 1 reply; 13+ messages in thread
From: James Courtier-Dutton @ 2004-03-25 15:13 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Paul Davis, alsa-devel

Jaroslav Kysela wrote:
> On Wed, 24 Mar 2004, Paul Davis wrote:
> 
> 
>>>open pcm, and get a handle.
>>>
>>>snd_pcm_poll_descriptors(handle, &pfd, err);
>>>
>>>Get a poll file scriptor in pfd.
>>>
>>>select(nfds, rfds, wfds, efds, tvp);
>>>
>>>Is it possible to use this call with alsa ?
>>
>>select is generally deprecated in linux (linus says so!). but you can
>>use the same pfds in select as in poll (select is implemented in the
>>kernel using the poll code). the problem is interpreting the results
>>you get back (as noted recently for the dmix plugin).
> 
> 
> Nope, the application must give results back to pfd array and call
> snd_pcm_poll_descriptors_revents() function. In this way, everything
> will work as expected.
> 
> 						Jaroslav
So which of the following is needed: -

snd_pcm_poll_descriptors(handle, &pfd, err);
select(nfds, rfds, wfds, efds, tvp);
snd_pcm_poll_descriptors_revents()  <- decode the results of the select.

or
snd_pcm_poll_descriptors(handle, &pfd, err);
snd_pcm_poll_descriptors_revents()  <- rearrange the pfd so that select 
works as expected.
select(nfds, rfds, wfds, efds, tvp);

Cheers
James


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 15:13     ` James Courtier-Dutton
@ 2004-03-25 15:38       ` Jaroslav Kysela
  0 siblings, 0 replies; 13+ messages in thread
From: Jaroslav Kysela @ 2004-03-25 15:38 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: Paul Davis, alsa-devel

On Thu, 25 Mar 2004, James Courtier-Dutton wrote:

> Jaroslav Kysela wrote:
> > On Wed, 24 Mar 2004, Paul Davis wrote:
> > 
> > 
> >>>open pcm, and get a handle.
> >>>
> >>>snd_pcm_poll_descriptors(handle, &pfd, err);
> >>>
> >>>Get a poll file scriptor in pfd.
> >>>
> >>>select(nfds, rfds, wfds, efds, tvp);
> >>>
> >>>Is it possible to use this call with alsa ?
> >>
> >>select is generally deprecated in linux (linus says so!). but you can
> >>use the same pfds in select as in poll (select is implemented in the
> >>kernel using the poll code). the problem is interpreting the results
> >>you get back (as noted recently for the dmix plugin).
> > 
> > 
> > Nope, the application must give results back to pfd array and call
> > snd_pcm_poll_descriptors_revents() function. In this way, everything
> > will work as expected.
> > 
> > 						Jaroslav
> So which of the following is needed: -
> 
> snd_pcm_poll_descriptors(handle, &pfd, err);
> select(nfds, rfds, wfds, efds, tvp);
> snd_pcm_poll_descriptors_revents()  <- decode the results of the select.

This one. The *revents() function mangles the returned ->revents back to 
the useful meaning for applications.

> or
> snd_pcm_poll_descriptors(handle, &pfd, err);
> snd_pcm_poll_descriptors_revents()  <- rearrange the pfd so that select 
> works as expected.
> select(nfds, rfds, wfds, efds, tvp);

That's wrong.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: problems using select() on alsa pcm.
  2004-03-25 14:00     ` Takashi Iwai
  2004-03-25 14:35       ` Martijn Sipkema
@ 2004-03-25 21:44       ` Glenn Maynard
  1 sibling, 0 replies; 13+ messages in thread
From: Glenn Maynard @ 2004-03-25 21:44 UTC (permalink / raw)
  To: alsa-devel

On Thu, Mar 25, 2004 at 03:00:58PM +0100, Takashi Iwai wrote:
> > Why is select deprecated?
> 
> because select is just a wrapper of poll in fact (on linux)?

So?  There are a few other operating systems out there, and select() is
very portable.

(select isn't deprecated; it's simply not Linus's API to deprecate. :)

-- 
Glenn Maynard


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-03-25 21:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-25  3:39 problems using select() on alsa pcm James Courtier-Dutton
2004-03-25  4:08 ` Paul Davis
2004-03-25  9:38   ` Jaroslav Kysela
2004-03-25 14:44     ` Paul Davis
2004-03-25 15:05       ` Jaroslav Kysela
2004-03-25 15:13     ` James Courtier-Dutton
2004-03-25 15:38       ` Jaroslav Kysela
2004-03-25 10:25   ` Martijn Sipkema
2004-03-25 13:19     ` Paul Davis
2004-03-25 14:00     ` Takashi Iwai
2004-03-25 14:35       ` Martijn Sipkema
2004-03-25 21:44       ` Glenn Maynard
2004-03-25  9:36 ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.