From e7410b8ed8b3bc821fb93c7bf359953ee6387a5a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 4 Feb 2020 22:24:54 -0500 Subject: [PATCH] Uses objective clock for updates. --- OSBindings/Mac/Clock Signal/Machine/CSMachine.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index f1e3a31a7..82c407710 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -720,10 +720,16 @@ struct ActivityObserver: public Activity::Observer { #define TICKS 600 - (void)start { + __block auto lastTime = std::chrono::high_resolution_clock::now().time_since_epoch().count(); + _timer = [[CSHighPrecisionTimer alloc] initWithTask:^{ + const auto timeNow = std::chrono::high_resolution_clock::now().time_since_epoch().count(); + const auto duration = timeNow - lastTime; + lastTime = timeNow; + CGSize pixelSize; @synchronized(self) { - self->_machine->crt_machine()->run_for(1.0 / double(TICKS)); + self->_machine->crt_machine()->run_for((double)duration / 1e9); pixelSize = self->_pixelSize; }