diff options
author | David Robillard <d@drobilla.net> | 2023-10-07 21:26:58 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-10-07 21:26:58 -0400 |
commit | 377979b723f0c1bae1ff239ea3d99c0422f7d4a9 (patch) | |
tree | 4bfcc41e50108ed63c5326e65d77fb096c402cfe /src/mac.m | |
parent | 880b7766181f763d7fdd1267a981bbebb0d7ea72 (diff) | |
download | pugl-377979b723f0c1bae1ff239ea3d99c0422f7d4a9.tar.gz pugl-377979b723f0c1bae1ff239ea3d99c0422f7d4a9.tar.bz2 pugl-377979b723f0c1bae1ff239ea3d99c0422f7d4a9.zip |
Fix puglGetTime() on Apple Silicon
The floating point precision of these chips is... strange.
Diffstat (limited to 'src/mac.m')
-rw-r--r-- | src/mac.m | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1646,9 +1646,11 @@ puglProcessEvents(PuglView* view) double puglGetTime(const PuglWorld* world) { - return ((double)mach_absolute_time() * world->impl->timebaseInfo.denom / - world->impl->timebaseInfo.numer / 1e9) - - world->startTime; + const struct mach_timebase_info base = world->impl->timebaseInfo; + const double rate = (1.0E9 / base.numer) * base.denom; + const double period = 1.0 / rate; + + return (double)mach_absolute_time() * period; } PuglStatus |