[LAD] Can someone add 2 features to Kluppe?

Patrick Shirkey pshirkey at boosthardware.com
Tue Jul 20 12:46:52 UTC 2010


On 07/20/2010 09:51 PM, Paul Davis wrote:
> On Tue, Jul 20, 2010 at 7:48 AM, Patrick Shirkey
> <pshirkey at boosthardware.com>  wrote:
>
>    
>>> A simple approach might be to just set a counter and have the
>>> audio-process count it down (in audio-samples). Once it reaches zero:
>>> play again.
>>>
>>>
>>>        
>> The problem is how to set a counter that doesn't block the rest of the app
>> while it is in process.
>>      
> i believe that robin's suggestion is the correct one. you don't want
> to attempt audio timing using the system clock unless you have a
> DLL/PLL that relates audio time to system time (and you don't).
> decisions about what to do as time progresses need to be made in the
> process() callback tree, not in the GUI or some other thread.
> so just countdown some number of samples, and then resume playing, as
> robin suggested. it won't block anything, anywhere.
>    

I don't have any problem with counting down using the audio clock but 
how do I translate that into seconds/milliseconds set in the ui?

At the moment the timer counts in seconds using this function

void *timer_thread(void *arg) {
     int how_long = *((int*) arg);
     sleep(how_long);
     pthread_mutex_unlock(&timer_lock);
     return NULL;
}

While it is counting I set the volume for the per track playback buffer 
to zero. I also need to stop the playhead from moving but that is a 
seperate issue.

Ideally the timer should count in milliseconds which I guess is handled 
by changing the call to sleep to select instead?

ex.

void *timer_thread(void *arg) {
     int how_long = *((int*) arg);
     pause.tv_sec  = how_long;
     pause.tv_usec = 0;
     (void) select(0, 0, 0, 0, &pause);
     pthread_mutex_unlock(&timer_lock);
     return NULL;
}


I'm not sure how to do that with audio samples instead. Happy to make it 
work that way though if it is the best approach.



-- 
Patrick Shirkey
Boost Hardware Ltd




More information about the Linux-audio-dev mailing list