2011-01-04 02:45:53 +00:00
|
|
|
#import <Foundation/NSString.h>
|
2020-05-11 15:52:05 +00:00
|
|
|
#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
|
|
|
|
2020-05-11 15:52:05 +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
|
|
|
|
2020-05-11 15:52:05 +00:00
|
|
|
return 0.000000001 * ((double) timebase.numer / (double) timebase.denom);
|
2011-01-04 02:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CFTimeInterval CACurrentMediaTime(void) {
|
2020-05-11 15:52:05 +00:00
|
|
|
uint64_t value = mach_absolute_time();
|
2011-01-04 02:45:53 +00:00
|
|
|
|
2020-05-11 15:52:05 +00:00
|
|
|
return ((double) value) * conversionFactor();
|
2011-01-04 02:45:53 +00:00
|
|
|
}
|