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:
parent
8275bc3c08
commit
35f0a47938
1 changed files with 49 additions and 1 deletions
|
@ -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"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue