[APU] Fix audio crashes during shutdown

This commit is contained in:
Herman S.
2026-02-09 13:39:43 +09:00
parent 6203d382e2
commit 9371e73d92
2 changed files with 25 additions and 2 deletions

View File

@@ -308,8 +308,13 @@ void XAudio2AudioDriver::Shutdown() {
template <typename Objects>
void XAudio2AudioDriver::ShutdownObjects(Objects& objects) {
// Stop the engine first to ensure no callbacks are in-flight before
// destroying voices and the callback object.
if (objects.audio) {
objects.audio->StopEngine();
}
if (objects.pcm_voice) {
objects.pcm_voice->Stop();
objects.pcm_voice->DestroyVoice();
objects.pcm_voice = nullptr;
}
@@ -320,7 +325,6 @@ void XAudio2AudioDriver::ShutdownObjects(Objects& objects) {
}
if (objects.audio) {
objects.audio->StopEngine();
objects.audio->Release();
objects.audio = nullptr;
}