All of lore.kernel.org
 help / color / mirror / Atom feed
* ALSA and select, poll, ... (interrupted system calls)
@ 2004-06-10 11:20 Nicolas Hüppelshäuser
  2004-06-16 16:53 ` Clemens Ladisch
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Hüppelshäuser @ 2004-06-10 11:20 UTC (permalink / raw)
  To: alsa-devel


Hi all!

I tried to implement a sleep function the following ways:

x select(0, NULL, NULL, &timeout);
x poll(...)
x nanosleep

but none of this worked. Select and poll return with an error code
"interrupted system call" and nanosleep is interrupted. I believe alsa to
be the reason for this but don't understand why.

Oh --- alsa version is 1.0.4.

Viele Gruesse / best regards
	Nicolas Hueppelshaeuser
--
nicolas hueppelshaeuser, emlix gmbh, http://www.emlix.com,




-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-10 11:20 ALSA and select, poll, ... (interrupted system calls) Nicolas Hüppelshäuser
@ 2004-06-16 16:53 ` Clemens Ladisch
  2004-06-18  6:54   ` Nicolas Hüppelshäuser
  0 siblings, 1 reply; 9+ messages in thread
From: Clemens Ladisch @ 2004-06-16 16:53 UTC (permalink / raw)
  To: Nicolas Hüppelshäuser; +Cc: alsa-devel

Nicolas Hüppelshäuser wrote:
> I tried to implement a sleep function the following ways:
>
> x select(0, NULL, NULL, &timeout);
> x poll(...)
> x nanosleep
>
> but none of this worked. Select and poll return with an error code
> "interrupted system call" and nanosleep is interrupted. I believe alsa to
> be the reason for this but don't understand why.

What does the ALSA code in your program do?  There won't be any
signals unless you have enabled asynchronous notifications using
SIGIO.


HTH
Clemens





-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-16 16:53 ` Clemens Ladisch
@ 2004-06-18  6:54   ` Nicolas Hüppelshäuser
  2004-06-18 17:21     ` Clemens Ladisch
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Hüppelshäuser @ 2004-06-18  6:54 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel


Clemens Ladisch wrote:
> What does the ALSA code in your program do?  There won't be any
> signals unless you have enabled asynchronous notifications using
> SIGIO.

You're right - the interruption occurs only if asynchronous notifications
is enabled;  I enable it via the  snd_async_add_pcm_handler  function.
The code itself does nothing very special: capturing and playing sound
data via mmap.

By now I workaround with a mixture of nanosleep/"time polling" (tracking
elapsed system time in a loop).  Is there a better way?

regards
	Nicolas




-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-18  6:54   ` Nicolas Hüppelshäuser
@ 2004-06-18 17:21     ` Clemens Ladisch
  2004-06-22 10:01       ` Nicolas Hüppelshäuser
  0 siblings, 1 reply; 9+ messages in thread
From: Clemens Ladisch @ 2004-06-18 17:21 UTC (permalink / raw)
  To: Nicolas Hüppelshäuser; +Cc: alsa-devel

Nicolas Hüppelshäuser wrote:
> Clemens Ladisch wrote:
> > What does the ALSA code in your program do?  There won't be any
> > signals unless you have enabled asynchronous notifications using
> > SIGIO.
>
> You're right - the interruption occurs only if asynchronous notifications
> is enabled;  I enable it via the  snd_async_add_pcm_handler  function.
> The code itself does nothing very special: capturing and playing sound
> data via mmap.
>
> By now I workaround with a mixture of nanosleep/"time polling" (tracking
> elapsed system time in a loop).  Is there a better way?

If you're waiting anyway, why don't you simply wait with poll?


Regards,
Clemens





-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-18 17:21     ` Clemens Ladisch
@ 2004-06-22 10:01       ` Nicolas Hüppelshäuser
  2004-06-22 11:39         ` Clemens Ladisch
  2004-06-24  8:12         ` Glenn Maynard
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Hüppelshäuser @ 2004-06-22 10:01 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel


On Fri, 18 Jun 2004, Clemens Ladisch wrote:

> Nicolas Hüppelshäuser wrote:
> > By now I workaround with a mixture of nanosleep/"time polling" (tracking
> > elapsed system time in a loop).  Is there a better way?
>
> If you're waiting anyway, why don't you simply wait with poll?

I need to wait a defined amount of time.
And it doesn't make a differecne whether using poll or nanosleep since
both get interrupted by alsa async signals.

regards
	Nicolas




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-22 10:01       ` Nicolas Hüppelshäuser
@ 2004-06-22 11:39         ` Clemens Ladisch
  2004-06-23  7:54           ` Nicolas Hüppelshäuser
  2004-06-24  8:12         ` Glenn Maynard
  1 sibling, 1 reply; 9+ messages in thread
From: Clemens Ladisch @ 2004-06-22 11:39 UTC (permalink / raw)
  To: Nicolas Hüppelshäuser; +Cc: alsa-devel

Nicolas Hüppelshäuser wrote:

> On Fri, 18 Jun 2004, Clemens Ladisch wrote:
>
> > Nicolas Hüppelshäuser wrote:
> > > By now I workaround with a mixture of nanosleep/"time polling" (tracking
> > > elapsed system time in a loop).  Is there a better way?
> >
> > If you're waiting anyway, why don't you simply wait with poll?
>
> I need to wait a defined amount of time.
> And it doesn't make a differecne whether using poll or nanosleep since
> both get interrupted by alsa async signals.

Then don't enable async signals.  Or do you need them for some other
reason than waiting for interesting events?


Regards,
Clemens





-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-22 11:39         ` Clemens Ladisch
@ 2004-06-23  7:54           ` Nicolas Hüppelshäuser
  2004-06-23 10:15             ` Clemens Ladisch
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Hüppelshäuser @ 2004-06-23  7:54 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel


On Tue, 22 Jun 2004, Clemens Ladisch wrote:

> Nicolas Hüppelshäuser wrote:
>
> > On Fri, 18 Jun 2004, Clemens Ladisch wrote:
> >
> > > Nicolas Hüppelshäuser wrote:
> > > > By now I workaround with a mixture of nanosleep/"time polling" (tracking
> > > > elapsed system time in a loop).  Is there a better way?
> > >
> > > If you're waiting anyway, why don't you simply wait with poll?
> >
> > I need to wait a defined amount of time.
> > And it doesn't make a differecne whether using poll or nanosleep since
> > both get interrupted by alsa async signals.
>
> Then don't enable async signals.  Or do you need them for some other
> reason than waiting for interesting events?

Depending on the configuration I have a callback registered via
snd_async_add_pcm_handler function. This enables the async signals. My
code relies on that 'callback functionality'. But perhaps it's possible to
turn async signals off temporarily before entering a sleep/poll/whatever
and switch them on again afterwards?

bye
	Nicolas




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-23  7:54           ` Nicolas Hüppelshäuser
@ 2004-06-23 10:15             ` Clemens Ladisch
  0 siblings, 0 replies; 9+ messages in thread
From: Clemens Ladisch @ 2004-06-23 10:15 UTC (permalink / raw)
  To: Nicolas Hüppelshäuser; +Cc: alsa-devel

Nicolas Hüppelshäuser wrote:
>
> On Tue, 22 Jun 2004, Clemens Ladisch wrote:
>
> > Then don't enable async signals.  Or do you need them for some other
> > reason than waiting for interesting events?
>
> Depending on the configuration I have a callback registered via
> snd_async_add_pcm_handler function. This enables the async signals. My
> code relies on that 'callback functionality'.

SA_RESTART is said to make "certain" system calls restartable over
signals. ALSA already uses this, so it seems it doesn't work in your
case.

> But perhaps it's possible to turn async signals off temporarily
> before entering a sleep/poll/whatever and switch them on again
> afterwards?

fcntl(F_SETFL) can reset the O_ASYNC flag of the file descriptor
returned by snd_async_handler_get_fd().


HTH
Clemens





-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

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

* Re: ALSA and select, poll, ... (interrupted system calls)
  2004-06-22 10:01       ` Nicolas Hüppelshäuser
  2004-06-22 11:39         ` Clemens Ladisch
@ 2004-06-24  8:12         ` Glenn Maynard
  1 sibling, 0 replies; 9+ messages in thread
From: Glenn Maynard @ 2004-06-24  8:12 UTC (permalink / raw)
  To: alsa-devel

On Tue, Jun 22, 2004 at 12:01:38PM +0200, Nicolas Hüppelshäuser wrote:
> > > By now I workaround with a mixture of nanosleep/"time polling" (tracking
> > > elapsed system time in a loop).  Is there a better way?
> >
> > If you're waiting anyway, why don't you simply wait with poll?
> 
> I need to wait a defined amount of time.
> And it doesn't make a differecne whether using poll or nanosleep since
> both get interrupted by alsa async signals.

What's wrong with nanosleep?  Its entire purpose is for sleeping across signals:

timespec ts = { 10, 0 }, rem;
while( nanosleep( &ts, &rem ) == -1 && errno == EINTR )
	ts = rem; // keep waiting

-- 
Glenn Maynard


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

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

end of thread, other threads:[~2004-06-24  8:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-10 11:20 ALSA and select, poll, ... (interrupted system calls) Nicolas Hüppelshäuser
2004-06-16 16:53 ` Clemens Ladisch
2004-06-18  6:54   ` Nicolas Hüppelshäuser
2004-06-18 17:21     ` Clemens Ladisch
2004-06-22 10:01       ` Nicolas Hüppelshäuser
2004-06-22 11:39         ` Clemens Ladisch
2004-06-23  7:54           ` Nicolas Hüppelshäuser
2004-06-23 10:15             ` Clemens Ladisch
2004-06-24  8:12         ` Glenn Maynard

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.