From 76acad90a64340accb983a7ffabbe8c1aecd97d7 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 23 Apr 2023 20:08:48 -0700 Subject: [PATCH] Qt: Only disable swapInterval when fast-forwarding --- src/platform/qt/DisplayGL.cpp | 8 +++++--- src/platform/qt/Window.cpp | 7 ------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index ff60ea50e..67443edc8 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -733,6 +733,7 @@ void PainterGL::start() { m_buffer = nullptr; m_active = true; m_started = true; + swapInterval(1); emit started(); } @@ -763,15 +764,16 @@ void PainterGL::draw() { } return; } - if (m_swapInterval != !!sync->videoFrameWait) { - swapInterval(!!sync->videoFrameWait); + int wantSwap = sync->audioWait || sync->videoFrameWait; + if (m_swapInterval != wantSwap) { + swapInterval(wantSwap); } dequeue(); bool forceRedraw = true; if (!m_delayTimer.isValid()) { m_delayTimer.start(); } else { - if (sync->audioWait || sync->videoFrameWait) { + if (wantSwap) { while (m_delayTimer.nsecsElapsed() + OVERHEAD_NSEC < 1000000000 / sync->fpsTarget) { QThread::usleep(500); } diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index b63e846e8..3bdf273c8 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -1789,13 +1789,6 @@ void Window::setupMenu(QMenuBar* menubar) { void Window::setupOptions() { ConfigOption* videoSync = m_config->addOption("videoSync"); videoSync->connect([this](const QVariant& variant) { - if (m_display) { - bool ok; - int interval = variant.toInt(&ok); - if (ok) { - m_display->swapInterval(interval); - } - } reloadConfig(); }, this);