Audio: Handle the backend disconnected event
libsoundio panics by default when a backend disconnects, this catches that event and gracefully handles it.
This commit is contained in:
parent
35f0a47938
commit
59b602fb96
1 changed files with 12 additions and 2 deletions
|
@ -39,24 +39,34 @@ namespace Ryujinx.Audio
|
|||
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)
|
||||
if(device == null || backendDisconnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stream = device.CreateOutStream();
|
||||
|
||||
if(stream == null)
|
||||
if(stream == null || backendDisconnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue