From fe1b6812f1c04dec648ace69c57551c4cdfedf4f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 6 Jun 2020 19:47:35 -0400 Subject: [PATCH] Fixes processing cap and attempts full-rate video output. Audio now seems to be present, though hugely stuttered. --- OSBindings/Qt/mainwindow.cpp | 2 ++ OSBindings/Qt/scantargetwidget.cpp | 14 +++++++++++++- OSBindings/Qt/timer.cpp | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index e353e6b93..ffd5fc413 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -181,6 +181,8 @@ void MainWindow::launchMachine() { audioOutput = std::make_unique(idealFormat, this); audioOutput->setBufferSize(samplesPerBuffer * (audioIsStereo ? 2 : 1) * (audioIs8bit ? 1 : 2)); + qDebug() << idealFormat; + // Start the output. speaker->set_delegate(this); audioIODevice = audioOutput->start(); diff --git a/OSBindings/Qt/scantargetwidget.cpp b/OSBindings/Qt/scantargetwidget.cpp index 33c133425..e3fb202ab 100644 --- a/OSBindings/Qt/scantargetwidget.cpp +++ b/OSBindings/Qt/scantargetwidget.cpp @@ -4,12 +4,16 @@ #include #include +#include "../../ClockReceiver/TimeTypes.hpp" + ScanTargetWidget::ScanTargetWidget(QWidget *parent) : QOpenGLWidget(parent) {} ScanTargetWidget::~ScanTargetWidget() {} void ScanTargetWidget::initializeGL() { glClearColor(0.5, 0.5, 1.0, 1.0); + // Follow each swapped frame with an additional update. + connect(this, SIGNAL(frameSwapped()), this, SLOT(update())); // qDebug() << "share context: " << bool(context()->shareGroup()); } @@ -18,7 +22,15 @@ void ScanTargetWidget::paintGL() { if(scanTarget) { scanTarget->update(width(), height()); scanTarget->draw(width(), height()); - QTimer::singleShot(500, this, SLOT(update())); // TODO: obviously this is nonsense. + +// static int64_t start = 0; +// static int frames = 0; +// if(!start) start = Time::nanos_now(); +// else { +// ++frames; +// const int64_t now = Time::nanos_now(); +// qDebug() << double(frames) * 1e9 / double(now - start); +// } } } diff --git a/OSBindings/Qt/timer.cpp b/OSBindings/Qt/timer.cpp index 5081e188c..292c0e16d 100644 --- a/OSBindings/Qt/timer.cpp +++ b/OSBindings/Qt/timer.cpp @@ -14,7 +14,8 @@ void Timer::setMachine(MachineTypes::TimedMachine *machine, std::mutex *machineM void Timer::tick() { const auto now = Time::nanos_now(); - const auto duration = std::min(now - lastTickNanos, int64_t(500'000)); + 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);