From 686b63e4794b975f8bb3cc5e03b2c9063c4d045f Mon Sep 17 00:00:00 2001 From: VocalFan <45863583+Mou-Ikkai@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:03:19 -0400 Subject: [PATCH] Added fallbacks for all Audio Backends (#2582) * Added fallbacks for all Audio Backends * Commit Suggestion Co-authored-by: gdkchan * Resolve elses. * Revert "Resolve elses." This reverts commit 9aec3e9e7750803e5626da3d01d7e57fabe19f65. * Suggestions completed Co-authored-by: gdkchan --- Ryujinx/Configuration/ConfigurationState.cs | 2 +- Ryujinx/Ui/MainWindow.cs | 86 +++++++++++++++++++-- 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/Ryujinx/Configuration/ConfigurationState.cs b/Ryujinx/Configuration/ConfigurationState.cs index fe4ff774..57e449c3 100644 --- a/Ryujinx/Configuration/ConfigurationState.cs +++ b/Ryujinx/Configuration/ConfigurationState.cs @@ -519,7 +519,7 @@ namespace Ryujinx.Configuration System.EnablePtc.Value = true; System.EnableFsIntegrityChecks.Value = true; System.FsGlobalAccessLogMode.Value = 0; - System.AudioBackend.Value = AudioBackend.OpenAl; + System.AudioBackend.Value = AudioBackend.SDL2; System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe; System.ExpandRam.Value = false; System.IgnoreMissingServices.Value = false; diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index c4c161c0..e13d70f9 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -411,7 +411,35 @@ namespace Ryujinx.Ui } else { - Logger.Warning?.Print(LogClass.Audio, "SDL2 audio is not supported, falling back to dummy audio out."); + Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to OpenAL."); + + if (OpenALHardwareDeviceDriver.IsSupported) + { + Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration."); + + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl; + SaveConfig(); + + deviceDriver = new OpenALHardwareDeviceDriver(); + } + else + { + Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO."); + + if (SoundIoHardwareDeviceDriver.IsSupported) + { + Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration."); + + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo; + SaveConfig(); + + deviceDriver = new SoundIoHardwareDeviceDriver(); + } + else + { + Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out."); + } + } } } else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo) @@ -422,7 +450,35 @@ namespace Ryujinx.Ui } else { - Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out."); + Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, trying to fall back to SDL2."); + + if (SDL2HardwareDeviceDriver.IsSupported) + { + Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration."); + + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2; + SaveConfig(); + + deviceDriver = new SDL2HardwareDeviceDriver(); + } + else + { + Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to OpenAL."); + + if (OpenALHardwareDeviceDriver.IsSupported) + { + Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration."); + + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl; + SaveConfig(); + + deviceDriver = new OpenALHardwareDeviceDriver(); + } + else + { + Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, falling back to dummy audio out."); + } + } } } else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.OpenAl) @@ -433,20 +489,34 @@ namespace Ryujinx.Ui } else { - Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO."); + Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SDL2."); - if (SoundIoHardwareDeviceDriver.IsSupported) + if (SDL2HardwareDeviceDriver.IsSupported) { - Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration."); + Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration."); - ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo; + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2; SaveConfig(); - deviceDriver = new SoundIoHardwareDeviceDriver(); + deviceDriver = new SDL2HardwareDeviceDriver(); } else { - Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out."); + Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to SoundIO."); + + if (SoundIoHardwareDeviceDriver.IsSupported) + { + Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration."); + + ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo; + SaveConfig(); + + deviceDriver = new SoundIoHardwareDeviceDriver(); + } + else + { + Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out."); + } } } }