fix potential heap corruption on audio shutdown

pull/53/head
cosmonaut 2023-12-08 15:06:17 -08:00
parent fcd08fe231
commit 528fb7ac7c
1 changed files with 4 additions and 4 deletions

View File

@ -292,16 +292,16 @@ namespace MoonWorks.Audio
{ {
Thread.Join(); Thread.Join();
// stop all source voices // dispose all voices first
foreach (var resource in resources) foreach (var resource in resources)
{ {
if (resource.Target is SourceVoice voice) if (resource.Target is Voice voice)
{ {
voice.Stop(); voice.Dispose();
} }
} }
// destroy all audio resources // destroy all other audio resources
foreach (var resource in resources) foreach (var resource in resources)
{ {
if (resource.Target is IDisposable disposable) if (resource.Target is IDisposable disposable)