RE: Recommend way for an Audio Unit to implement a background timer
RE: Recommend way for an Audio Unit to implement a background timer
- Subject: RE: Recommend way for an Audio Unit to implement a background timer
- From: "Muon Software Ltd - Dave" <email@hidden>
- Date: Sat, 21 Feb 2009 10:25:23 -0000
- Thread-topic: Recommend way for an Audio Unit to implement a background timer
> Could you post the code that creates + adds the timer, and the empty
> callback?
if (m_platformTimer==NULL)
{
#ifdef PLATFORM_OSX
CFRunLoopTimerContext timerContext={0};
timerContext.info=this;
m_platformTimer=CFRunLoopTimerCreate(kCFAllocatorDefault,
CFAbsoluteTimeGetCurrent()+(float)m_nFireTime*0.001f,
(float)m_nFireTime*0.001f, 0, 0, timerCallback, &timerContext);
if (m_platformTimer)
{
CFRunLoopAddTimer(CFRunLoopGetCurrent(),
(CFRunLoopTimerRef)m_platformTimer, kCFRunLoopCommonModes);
}
#elif PLATFORM_WIN32
...etc
The callback looks like
void CMuonTimer::timerCallback (CFRunLoopTimerRef t, void *info)
{
CMuonTimer* timer=(CMuonTimer*)info;
if (timer->m_listener!=NULL)
{
timer->m_listener->timerFired(timer);
}
};
as I say, the code is derived from the cvstguitimer class included in
VSTGUI 3.5. Now I'm not using VSTGUI3.5 so I had to tidy up a few
dependencies and made adjustments to variable names etc. to conform to
our coding standard.
> Also, are you sure you're adding the timer from the main thread?
I can't be sure of what thread the Audio Unit is being instantiated or
initialised from. I've tried calling it from both the AU constructor and
Initialize so far, can't think of anywhere else that would be
appropriate. Note I can't install this timer on the editor, I need
something that runs in the background when the AU is running and the GUI
may or may not be open, and the audio thread may or may not be polling
the AU for renders.
Kind regards + thanks for your help
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden