darling-cocotron/QuartzCore/CABase.m

22 lines
551 B
Mathematica
Raw Normal View History

2011-01-04 02:45:53 +00:00
#import <Foundation/NSString.h>
#import <QuartzCore/CABase.h>
#import <mach/mach_time.h>
static double conversionFactor() {
struct mach_timebase_info timebase;
kern_return_t error;
2011-01-04 02:45:53 +00:00
if ((mach_timebase_info(&timebase)) != KERN_SUCCESS) {
NSLog(@"mach_timebase_info returned %d", error);
return 1;
}
2011-01-04 02:45:53 +00:00
return 0.000000001 * ((double) timebase.numer / (double) timebase.denom);
2011-01-04 02:45:53 +00:00
}
CFTimeInterval CACurrentMediaTime(void) {
uint64_t value = mach_absolute_time();
2011-01-04 02:45:53 +00:00
return ((double) value) * conversionFactor();
2011-01-04 02:45:53 +00:00
}