Juce 3.2.0 Mac OS 10.10.5
I've just started a Juce project that requires a high resolution timer thread. I noticed what seems to be an inconsistency in handling OS X "absolute time" in juce_posix_SharedCode.h
In setThreadToRealtime we have this:
#if JUCE_MAC || JUCE_IOS
thread_time_constraint_policy_data_t policy;
policy.period = (uint32_t) (periodMs * 1000000);
policy.computation = 50000;
policy.constraint = policy.period;
policy.preemptible = true;
This is assuming that the absolute time is in units of nanoseconds, which is usually true, but technically we're supposed to be adjusting this
by mach_timebase_info_data_t, which you do correctly when calculating the Clock wait delta:
#if JUCE_MAC || JUCE_IOS
Clock (double millis) noexcept
{
mach_timebase_info_data_t timebase;
(void) mach_timebase_info (&timebase);
delta = (((uint64_t) (millis * 1000000.0)) * timebase.denom) / timebase.numer;
time = mach_absolute_time();
}
The result is the same as long as timebase.denom and timebase.numer are both 1 but that isn't necessarily the case. This person thinks it can be different on some iOS devices:
http://iosdeveloperzone.com/2011/05/03/quick-performance-measurements/
Regards,
Jeff