aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-10-07 21:26:58 -0400
committerDavid Robillard <d@drobilla.net>2023-10-07 21:26:58 -0400
commit377979b723f0c1bae1ff239ea3d99c0422f7d4a9 (patch)
tree4bfcc41e50108ed63c5326e65d77fb096c402cfe /src
parent880b7766181f763d7fdd1267a981bbebb0d7ea72 (diff)
downloadpugl-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')
-rw-r--r--src/mac.m8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mac.m b/src/mac.m
index fa5355f..07eb28d 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -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