I don't know anything about the kluppe code, but are the underlying libraries you're using re-entrant? My brief perusal<div>of your code raised red-flags due to use of signal(2) and alarm(2). Execution ends up jumping around asynchronously&&indeterminately, in audio code or threads that probably should never have that happen. For example. lets say you had a piece of code that needed to execute within a certain amount of time in order to generate a data-stream w/o interruption -- lowlevel code that never expected to be jumped out of to take care of some random "application level" business that it shouldn't need to concern itself over.</div>
<div><div><br></div><div>This probably requires an event-driven architecture, where everything is driven by IO. Looked at that way, a timer timing out is just another thing to select(2)  on; as long as your code doesn't block on I/O, you never need to worry about reentrancy.</div>
<div><br></div><div>Niels</div><div><a href="http://nielsmayer.com">http://nielsmayer.com</a><br><br><div class="gmail_quote">On Tue, Apr 20, 2010 at 6:12 AM, Patrick Shirkey <span dir="ltr"><<a href="mailto:pshirkey@boosthardware.com">pshirkey@boosthardware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I'm trying to add a threaded timer to kluppes looperdata.c<br>
looperdata_calc_sample_stereo function so that I can add a delayed<br>
restart to the loop process.<br>
<br>
Can anyone tell me why the "while" statement in the following code locks<br>
up the audio stream for the loop it is being run on? I end up with a<br>
buzz throughout the delay period instead of a nice quiet delay period.<br>
<br>
<br>
<br>
#include <stdlib.h><br>
#include <signal.h><br>
#include <stdio.h><br>
<br>
/* This flag controls termination of the main loop.  */<br>
volatile sig_atomic_t isdelay_countdown = 1;<br>
<br>
/* The signal handler just clears the flag and re-enables itself.  */<br>
void catch_alarm (int sig){<br>
   isdelay_countdown = 0;<br>
   signal (sig, catch_alarm);<br>
}<br>
<br>
<br>
<br>
     vol = data->vol;<br>
<br>
                 if(data->playbackdelay > 0){<br>
<br>
                     /* Establish a handler for SIGALRM signals.  */<br>
                     signal (SIGALRM, catch_alarm);<br>
<br>
                      isdelay_countdown = 1;<br>
<br>
                       /* Call alarm to countdown length of<br>
playbackdelay  */<br>
                       alarm ((int)data->playbackdelay);<br>
<br>
                       /* Check the flag once in a while to see when to<br>
quit.  */<br>
                       while(isdelay_countdown){<br>
                         looperdata_set_vol(data,0);<br>
                         data->isplaying = 0;<br>
                      }<br>
<br>
<br>
                 }<br>
<br>
/* return to start of loop */<br>
<br>
                     looperdata_set_vol(data,vol);<br>
                     data->isplaying = 1;<br>
                     data->playindex += data->loopstart - data->loopend;<br>
<font color="#888888"><br>
<br>
<br>
<br>
--<br>
Patrick Shirkey<br>
Boost Hardware Ltd<br>
<br>
_______________________________________________<br>
Linux-audio-dev mailing list<br>
<a href="mailto:Linux-audio-dev@lists.linuxaudio.org">Linux-audio-dev@lists.linuxaudio.org</a><br>
<a href="http://lists.linuxaudio.org/listinfo/linux-audio-dev" target="_blank">http://lists.linuxaudio.org/listinfo/linux-audio-dev</a><br>
</font></blockquote></div><br></div></div>