1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-29 16:29:08 +00:00
CLK/OSBindings/Qt/timer.cpp
Thomas Harte fe1b6812f1 Fixes processing cap and attempts full-rate video output.
Audio now seems to be present, though hugely stuttered.
2020-06-06 19:47:35 -04:00

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);
}