[LAD] Can someone add 2 features to Kluppe?

Robin Gareus robin at gareus.org
Tue Jul 20 12:16:55 UTC 2010


On 07/20/2010 01:48 PM, Patrick Shirkey wrote:
> On 07/20/2010 06:54 PM, Robin Gareus wrote:
>> On 07/20/2010 09:17 AM, Patrick Shirkey wrote:
>>   
>>> On 07/20/2010 09:45 AM, Robin Gareus wrote:
>>>     
>>>> On 07/20/2010 01:06 AM, Louigi Verona wrote:
>>>>
>>>>       
>>>>> Hey guys!
>>>>>
>>>>> Some time ago I have asked someone to look into Kluppe and add a
>>>>> couple of
>>>>> features.
>>>>> My request was not ignored and Patrick Shirkey was kind enough to
>>>>> volunteer
>>>>> to try to help.
>>>>>
>>>>> However, he came upon a difficulty and that is - *how do you set up an
>>>>> asynchronous timer in C?*
>>>>>
>>>>>          
>>>> It depends what you need that timer for.
>>>>
>>>>
>>>>        
>>> The timer is needed to countdown the period between stopping and
>>> restarting the loop. The methods I have tried all halt the playback on a
>>> single frame and the ui also becomes unresponsive while the timer is in
>>> process.
>>>      
>> That sounds like it needs to be be quite accurate, or not?
>>
>>    
> 
> It just needs to work ;-)

Are you really sure? :-p


>>> All I would like to do is pass a zero byte to the audio signal handling
>>> code while the timer is in progress. The rest of the interface should
>>> stay active.
>>>      
>> 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.
> 

Outline:

global:
static long int mycounter = 0;

main-thread:
 if (need_to pause) mycounter = time_to_pause * sample_rate;

audio-thread:
 if (mycounter > 0) { mycounter -= samples_processed_here; }
 if (mycounter > 0) mute;
 else play;


The 'mycounter' variable does not need to be global. It can be part of
the track struct or class eg. track->mutecounter.
..and eventually you implement it to be sample-accurate (the above is
just an outline).

Cheers!
robin

-- 
Robin Gareus                           mail: robin at gareus.org
site: http://gareus.org/               chat: xmpp:rgareus at ik.nu
blog: http://rg42.org/                 lab : http://citu.fr/

Public Key at http://pgp.mit.edu/
Fingerprint : 7107 840B 4DC9 C948 076D 6359 7955 24F1 4F95 2B42



More information about the Linux-audio-dev mailing list