Fix disposing of IPC sessions server at emulation stop (#2334)

This commit is contained in:
Mary 2021-06-29 19:37:13 +02:00 committed by GitHub
parent fbb4019ed5
commit 00ce9eea62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 284 additions and 123 deletions

View file

@ -133,19 +133,28 @@ namespace Ryujinx.Audio.Backends.OpenAL
{
if (disposing)
{
lock (_lock)
{
_stillRunning = false;
_updaterThread.Join();
_stillRunning = false;
// Loop against all sessions to dispose them (they will unregister themself)
while (_sessions.Count > 0)
int sessionCount = 0;
// NOTE: This is done in a way to avoid possible situations when the OpenALHardwareDeviceSession is already being dispose in another thread but doesn't hold the lock and tries to Unregister.
do
{
lock (_lock)
{
OpenALHardwareDeviceSession session = _sessions[0];
if (_sessions.Count == 0)
{
break;
}
OpenALHardwareDeviceSession session = _sessions[_sessions.Count - 1];
session.Dispose();
sessionCount = _sessions.Count;
}
}
while (sessionCount > 0);
ALC.DestroyContext(_context);
ALC.CloseDevice(_device);