mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-10 13:43:17 +02:00
Audio: Properly implements audio fallback for SoundIO (#500)
* 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.
* Audio: Handle the backend disconnected event
libsoundio panics by default when a backend disconnects, this catches that event and gracefully handles it.
* Audio: Fix styling nits
* Audio: Fix nits
Because Ac_K. 😫
This commit is contained in:
parent
ad98558295
commit
5829e36a5c
@ -32,7 +32,66 @@ namespace Ryujinx.Audio
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if SoundIO is supported on the device.
|
/// True if SoundIO is supported on the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsSupported => true;
|
public static bool IsSupported
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
SoundIO context = null;
|
||||||
|
SoundIODevice device = null;
|
||||||
|
SoundIOOutStream stream = null;
|
||||||
|
|
||||||
|
bool backendDisconnected = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
context = new SoundIO();
|
||||||
|
|
||||||
|
context.OnBackendDisconnect = (i) => {
|
||||||
|
backendDisconnected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
context.Connect();
|
||||||
|
context.FlushEvents();
|
||||||
|
|
||||||
|
if(backendDisconnected)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
device = context.GetOutputDevice(context.DefaultOutputDeviceIndex);
|
||||||
|
|
||||||
|
if(device == null || backendDisconnected)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream = device.CreateOutStream();
|
||||||
|
|
||||||
|
if(stream == null || backendDisconnected)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if(stream != null)
|
||||||
|
{
|
||||||
|
stream.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(context != null)
|
||||||
|
{
|
||||||
|
context.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructs a new instance of a <see cref="SoundIoAudioOut"/>
|
/// Constructs a new instance of a <see cref="SoundIoAudioOut"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user