Re: Polling a Clock
Re: Polling a Clock
- Subject: Re: Polling a Clock
- From: Jeff Moore <email@hidden>
- Date: Wed, 12 May 2010 08:53:28 -0700
Not to pry, but why do you need to poll the clock so frequently? Polling a clock for the time in seconds at 1ms intervals seems excessive to me. It is definitely overkill and frankly wasteful if you are simply driving UI and probably is wasteful even if you aren't. Do you really have a need for that kind of resolution? I suspect that you don't since you don't seem to care about drift in your polling duty cycle (at least as evidenced in the code you presented).
Typically your best bet is to tie the polling to something else you are already doing that frequently, like say the render callback of any audio IO you might be doing or whatever real-time process is driving this need to poll the clock. The reason why is that generally you don't need to look at the clock any more frequently than the duty cycle of your IO. But even then the need to poll the clock (or to even use a clock) is somewhat mitigated by the fact that all our render contexts pass around time stamps already.
On May 12, 2010, at 4:07 AM, Maximilian Marcoll wrote:
>
> Hello Everybody!
>
> I'm having some difficulties figuring out the best way to poll a CAClock.
> To "trigger" objects in an array at specific points in time, I set up a CAClock, and use CAClockGetCurrentTime()
> within a loop to determine if there are objects I have to trigger.
>
> My code looks something like this:
>
> while( [list count] ) {
> CAClockGetCurrentTime(clock, kCAClockTimeFormat_Seconds, &T);
> // display current time
> while( [list count] && T.time.seconds >= [[list objectAtIndex:0] start]){
> [[list objectAtIndex:0] trigger];
> [list removeObjectAtIndex:0];
> }
> }
>
>
> Polling a clock like this seems to be a bit extreme.
> (This code actually activates my MacBook's fan ;o)
> I thought maybe I could use a CFRunLoop, but it's use of NSTimers would be a problem I think.
> I would need to poll the clock every millisecond.
> What would you do?
>
> Thank you!
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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