mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-29 16:29:08 +00:00
fe1b6812f1
Audio now seems to be present, though hugely stuttered.
24 lines
624 B
C++
24 lines
624 B
C++
#include "timer.h"
|
|
|
|
#include "../../ClockReceiver/TimeTypes.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <QDebug>
|
|
|
|
Timer::Timer(QObject *parent) : QObject(parent) {}
|
|
|
|
void Timer::setMachine(MachineTypes::TimedMachine *machine, std::mutex *machineMutex) {
|
|
this->machine = machine;
|
|
this->machineMutex = machineMutex;
|
|
}
|
|
|
|
void Timer::tick() {
|
|
const auto now = Time::nanos_now();
|
|
const auto duration = std::min(now - lastTickNanos, int64_t(500'000'000));
|
|
// qDebug() << duration << " [not " << now - lastTickNanos << "]";
|
|
lastTickNanos = now;
|
|
|
|
std::lock_guard lock_guard(*machineMutex);
|
|
machine->run_for(double(duration) / 1e9);
|
|
}
|