diff options
author | german77 <juangerman-13@hotmail.com> | 2022-02-06 20:46:22 -0600 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-02-06 20:46:58 -0600 |
commit | ab93b4c66de04db92ada60d41975bb8c111a7f87 (patch) | |
tree | 536350b66fc67f7eaf823097e9663316df275ece /src/yuzu/main.cpp | |
parent | 49eb78497b76af27b0403e7d2174aa368b07ddf1 (diff) |
yuzu: Mute audio when in background
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 68cd9f6eaa..cc5a8f65ef 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1034,14 +1034,14 @@ void GMainWindow::RestoreUIState() { } void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { - if (!UISettings::values.pause_when_in_background) { - return; - } if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && state != Qt::ApplicationActive) { LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); } - if (emulation_running) { + if (!emulation_running) { + return; + } + if (UISettings::values.pause_when_in_background) { if (emu_thread->IsRunning() && (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { auto_paused = true; @@ -1051,6 +1051,16 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { OnStartGame(); } } + if (UISettings::values.mute_when_in_background) { + if (!Settings::values.audio_muted && + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + Settings::values.audio_muted = true; + auto_muted = true; + } else if (auto_muted && state == Qt::ApplicationActive) { + Settings::values.audio_muted = false; + auto_muted = false; + } + } } void GMainWindow::ConnectWidgetEvents() { |