audio disposal is friggin haunted man

cosmonaut 2023-12-12 19:29:45 -08:00
parent c28c4a9db0
commit a9dd3dc13f
2 changed files with 20 additions and 6 deletions

View File

@ -292,15 +292,30 @@ namespace MoonWorks.Audio
{
Thread.Join();
// dispose all voices first
// dispose all source voices first
foreach (var resource in resources)
{
if (resource.Target is Voice voice)
if (resource.Target is SourceVoice voice)
{
voice.Dispose();
}
}
// dispose all submix voices except the faux mastering voice
foreach (var resource in resources)
{
if (resource.Target is SubmixVoice voice && voice != fauxMasteringVoice)
{
voice.Dispose();
}
}
// dispose the faux mastering voice
fauxMasteringVoice.Dispose();
// dispose the true mastering voice
FAudio.FAudioVoice_DestroyVoice(trueMasteringVoice);
// destroy all other audio resources
foreach (var resource in resources)
{
@ -313,7 +328,6 @@ namespace MoonWorks.Audio
resources.Clear();
}
FAudio.FAudioVoice_DestroyVoice(trueMasteringVoice);
FAudio.FAudio_Release(Handle);
IsDisposed = true;

View File

@ -109,9 +109,6 @@ namespace MoonWorks
Logger.LogInfo("Cleaning up game...");
Destroy();
Logger.LogInfo("Closing audio thread...");
AudioDevice.Dispose();
Logger.LogInfo("Unclaiming window...");
GraphicsDevice.UnclaimWindow(MainWindow);
@ -121,6 +118,9 @@ namespace MoonWorks
Logger.LogInfo("Disposing graphics device...");
GraphicsDevice.Dispose();
Logger.LogInfo("Closing audio thread...");
AudioDevice.Dispose();
SDL.SDL_Quit();
}