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.
This commit is contained in:
jduncanator 2018-11-17 00:12:16 +11:00
parent 8275bc3c08
commit 35f0a47938

View file

@ -32,7 +32,55 @@ namespace Ryujinx.Audio
/// <summary>
/// True if SoundIO is supported on the device.
/// </summary>
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();
}
}
}
}
/// <summary>
/// Constructs a new instance of a <see cref="SoundIoAudioOut"/>