• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Recommend way for an Audio Unit to implement a background timer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Recommend way for an Audio Unit to implement a background timer
      • From: Jens Alfke <email@hidden>
References: 
 >Recommend way for an Audio Unit to implement a background timer (From: "Muon Software Ltd - Dave" <email@hidden>)
 >Re: Recommend way for an Audio Unit to implement a background timer (From: Jens Alfke <email@hidden>)
 >RE: Recommend way for an Audio Unit to implement a background timer (From: "Muon Software Ltd - Dave" <email@hidden>)
 >Re: Recommend way for an Audio Unit to implement a background timer (From: Jens Alfke <email@hidden>)

  • Prev by Date: RE: Debugging cocoa
  • Next by Date: MIDI, basic approach question
  • Previous by thread: Re: Recommend way for an Audio Unit to implement a background timer
  • Next by thread: Re: Recommend way for an Audio Unit to implement a background timer
  • Index(es):
    • Date
    • Thread