From 9f0617f6ee8c0c115fbd8240947662239cb4ce60 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 22 Sep 2018 16:04:36 -0700 Subject: [PATCH] Gracefully fall back to stereo audio if 5.1 doesn't work --- app/streaming/session.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 3675b236..ea8926f1 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -512,8 +512,20 @@ bool Session::validateLaunch() } } - // Test that audio hardware is functional - m_AudioDisabled = !testAudio(m_StreamConfig.audioConfiguration); + // Test if audio works at the specified audio configuration + bool audioTestPassed = testAudio(m_StreamConfig.audioConfiguration); + + // Gracefully degrade to stereo if 5.1 doesn't work + if (!audioTestPassed && m_StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) { + audioTestPassed = testAudio(AUDIO_CONFIGURATION_STEREO); + if (audioTestPassed) { + m_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO; + emitLaunchWarning("5.1 surround sound is not supported by the current audio device."); + } + } + + // If nothing worked, warn the user that audio will not work + m_AudioDisabled = !audioTestPassed; if (m_AudioDisabled) { emitLaunchWarning("Failed to open audio device. Audio will be unavailable during this session."); }