<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Bert Freudenberg wrote:
<blockquote cite="mid8ADDC587-2BE1-40DF-BEB4-E044083FA6DA@impara.de"
 type="cite"><br>
Am 20.11.2005 um 03:42 schrieb Brad Fuller:
  <br>
  <br>
  <blockquote type="cite">The plugin that I'm creating seems to return
too quickly. I have a&nbsp; simple test that plays a sine wave and waits 5
seconds (using&nbsp; usleep). The problem is that it stops the sine wave and
returns in&nbsp; about a half a second (I hear the sine wave but just a
blip. And no&nbsp; errors from the external code.) The code works fine
outside of&nbsp; Squeak, but not called from Squeak.
    <br>
    <br>
The plugin does 2 simple things:
    <br>
* Starts a stream that calls a callback routine (below)
    <br>
* The callback fills a buffer for the sine wave data and then returns
    <br>
After waiting 5secs, the main line cleans up and exits.
    <br>
    <br>
Are there any particular issues with callbacks in Squeak? Do I need&nbsp; to
compile/link with anything special? It doesn't seem like this&nbsp; should
be a problem since Squeak is single-threaded. If anything, I&nbsp; would
think that the return would be slower not quicker. BTW,&nbsp; usleep returns
w/o error.
    <br>
    <br>
Any ideas or pointers much appreciated!
    <br>
  </blockquote>
  <br>
Did you wrap the usleep() into a while loop checking for EINTR?
  <br>
</blockquote>
googling, I found many instances of usleep to be a problem in
multithreading. One place said usleep sets an alarm signal to wait.
When it occurs, usleep returns. SIGALRM should not be blocked and if it
is, usleep will exit. This was my problem.<br>
<br>
I abandoned usleep and instead tried nanosleep. The result was the same
- I heard just a blip.<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
So, I wrapped the call to nanosleep with blocking the signals with
pthread_sigmask(), called nanosleep and then unblocked the signals.<br>
This worked. <br>
<br>
But, I don't know why. I still don't understand how this would effect
the call to the library from Squeak and not as a standalone. What is
different, or added, with Squeak that is not with the standalone test? <br>
<br>
brad<br>
</body>
</html>