I've noticed that the CAClock behaves that way as well. It seems that CAClockGetCurrentTime doesn't return useful information when the clock is not running. This is my code for dealing with it:
- (Float64)currentTimeSeconds { CAClockTime now; OSStatus err; if ([self isRunning]) err = CAClockGetCurrentTime(_clockRef, kCAClockTimeFormat_Seconds, &now); else err = CAClockGetStartTime(_clockRef, kCAClockTimeFormat_Seconds, &now);
if (err) { ZKMORLogError(kZKMORLogSource_Clock, CFSTR("CAClockGetStartTime failed %u"), err); return 0.f; } return now.time.seconds; }
On Jan 17, 2007, at 9:28 AM, Ferguson, Paul wrote:
Can anyone shed some light on the following problem ?
A simple coreaudio Clock experiment in cocoa - interface code removed but minimal anyway.. . . CAClockRef pfClockRef; CAClockTime pfTimestamp; OSStatus osErr; osErr = CAClockNew(0, &pfClockRef); // sucessfully creates a new clock - appears to default to internal timebase = host . . osErr = CAClockStart(pfClockRef); //sucessfully starts the clock . . osErr = CAClockGetCurrentTime(pfClockRef, kCAClockTimeFormat_Seconds, &pfTimestamp); //sucessfully prints running clock printf("currentTime... returned error code %d, current time is%f\n", osErr, pfTimestamp.time.seconds); . . osErr = CAClockStop(pfClockRef); //not what I expected !! - instead of stopping the clock, the current time is stored as the new clockStartTime and the clock continues to run.... . .
Many thanks in anticipation
Paul Fergy
-- C. Ramakrishnan
|