From 9989c51f21666ce3224621f045780cac896d6835 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 1 Jan 2020 07:47:26 -0800 Subject: [PATCH] SDL: Ignore audio switch events in first second. We get new device events right on start, which makes auto switch away from the preferred / most recent device otherwise. Fixes #12536. --- SDL/SDLMain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index f868592bd2..90db5d4195 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -910,7 +910,9 @@ int main(int argc, char *argv[]) { if (!name) { break; } - if (g_Config.bAutoAudioDevice || g_Config.sAudioDevice == name) { + // Don't start auto switching for a second, because some devices init on start. + bool doAutoSwitch = g_Config.bAutoAudioDevice && framecount > 60; + if (doAutoSwitch || g_Config.sAudioDevice == name) { StopSDLAudioDevice(); InitSDLAudioDevice(name ? name : ""); }