From 8fc3b7d552bae90ca35b609ea2c9770f58f92e6f Mon Sep 17 00:00:00 2001 From: Adam Higerd Date: Sun, 7 Dec 2025 16:45:31 -0600 Subject: [PATCH] Fix unexpected mute when window becomes focused while fast-forwarding --- CHANGES | 1 + src/platform/qt/CoreController.cpp | 8 +++----- src/platform/qt/CoreController.h | 2 +- src/platform/qt/Window.cpp | 6 +++--- src/platform/qt/Window.h | 1 + 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 34f9b4f139a..17e1e598edb 100644 --- a/CHANGES +++ b/CHANGES @@ -50,6 +50,7 @@ Other fixes: - Qt: Fix potential crash when configuring shortcuts - Qt: Fix regression where loading BIOS creates a save file (fixes mgba.io/i/3359) - Qt: Fix selecting high tiles in tile and map views (fixes mgba.io/i/3461) + - Qt: Fix unexpected mute when window becomes focused while fast-forwarding Misc: - 3DS: Change title ID to avoid conflict with commercial title (fixes mgba.io/i/3023) - Core: Handle relative paths for saves, screenshots, etc consistently (fixes mgba.io/i/2826) diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index f6f1db69d98..fcd1010af62 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -303,7 +303,7 @@ void CoreController::loadConfig(ConfigController* config) { m_autoload = config->getOption("autoload", true).toInt(); m_autofireThreshold = config->getOption("autofireThreshold", m_autofireThreshold).toInt(); m_fastForwardVolume = config->getOption("fastForwardVolume", -1).toInt(); - m_fastForwardMute = config->getOption("fastForwardMute", -1).toInt(); + m_fastForwardMute = config->getOption("fastForwardMute", false).toBool(); mCoreConfigCopyValue(&m_threadContext.core->config, config->config(), "volume"); mCoreConfigCopyValue(&m_threadContext.core->config, config->config(), "mute"); m_preload = config->getOption("preload", true).toInt(); @@ -640,7 +640,7 @@ void CoreController::overrideMute(bool override) { core->opts.mute = true; } else { if (m_fastForward || m_fastForwardForced) { - core->opts.mute = m_fastForwardMute >= 0; + core->opts.mute = m_fastForwardMute; } else { mCoreConfigGetBoolValue(&core->config, "mute", &core->opts.mute); } @@ -1306,9 +1306,7 @@ void CoreController::updateFastForward() { if (m_fastForwardVolume >= 0) { m_threadContext.core->opts.volume = m_fastForwardVolume; } - if (m_fastForwardMute >= 0) { - m_threadContext.core->opts.mute = m_fastForwardMute || m_mute; - } + m_threadContext.core->opts.mute = m_fastForwardMute || m_mute; setSync(false); // If we aren't holding the fast forward button diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index 5e0245e16cd..ca5ad75aacf 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -318,7 +318,7 @@ public slots: int m_fastForward = false; int m_fastForwardForced = false; int m_fastForwardVolume = -1; - int m_fastForwardMute = -1; + bool m_fastForwardMute = false; float m_fastForwardRatio = -1.f; float m_fastForwardHeldRatio = -1.f; float m_fpsTarget; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index c49e71a8bcc..50c3e5e1a49 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -732,7 +732,7 @@ void Window::showEvent(QShowEvent* event) { } if (m_config->getOption("muteOnMinimize").toInt()) { - m_inactiveMute = false; + m_minimizedMute = false; updateMute(); } } @@ -781,7 +781,7 @@ void Window::hideEvent(QHideEvent* event) { m_controller->setPaused(true); } if (m_config->getOption("muteOnMinimize").toInt()) { - m_inactiveMute = true; + m_minimizedMute = false; updateMute(); } } @@ -2336,7 +2336,7 @@ void Window::updateMute() { return; } - bool mute = m_inactiveMute; + bool mute = m_inactiveMute || m_minimizedMute; if (!mute) { QString multiplayerAudio = m_config->getQtOption("multiplayerAudio").toString(); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 16619cdf772..888224957fa 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -241,6 +241,7 @@ private slots: bool m_hitUnimplementedBiosCall; bool m_inactiveMute = false; + bool m_minimizedMute = false; bool m_multiActive = true; int m_playerId;