From 35f0a479382d59d20b3b210965d03161102d1073 Mon Sep 17 00:00:00 2001 From: jduncanator Date: Sat, 17 Nov 2018 00:12:16 +1100 Subject: [PATCH] Audio: Properly implements audio fallback for SoundIO Given some drivers have issues with SoundIO (for the time being), this attempts to detect if SoundIO can open the default audio device, and then return false in IsSupported if it can't. --- .../Renderers/SoundIo/SoundIoAudioOut.cs | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Audio/Renderers/SoundIo/SoundIoAudioOut.cs b/Ryujinx.Audio/Renderers/SoundIo/SoundIoAudioOut.cs index 76b1290d1b..5ee8944ca5 100644 --- a/Ryujinx.Audio/Renderers/SoundIo/SoundIoAudioOut.cs +++ b/Ryujinx.Audio/Renderers/SoundIo/SoundIoAudioOut.cs @@ -32,7 +32,55 @@ namespace Ryujinx.Audio /// /// True if SoundIO is supported on the device. /// - public static bool IsSupported => true; + public static bool IsSupported + { + get + { + SoundIO context = null; + SoundIODevice device = null; + SoundIOOutStream stream = null; + + try + { + context = new SoundIO(); + + context.Connect(); + context.FlushEvents(); + + device = context.GetOutputDevice(context.DefaultOutputDeviceIndex); + + if(device == null) + { + return false; + } + + stream = device.CreateOutStream(); + + if(stream == null) + { + return false; + } + + return true; + } + catch + { + return false; + } + finally + { + if(stream != null) + { + stream.Dispose(); + } + + if(context != null) + { + context.Dispose(); + } + } + } + } /// /// Constructs a new instance of a