From 89783bbdcee86f53d9340bbaa83c19a0a333bafe Mon Sep 17 00:00:00 2001 From: Mason Thompson <72317541+MasonT8198@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:17:34 -0400 Subject: [PATCH] apu.c: Kill audio subsystem if there are no playback devices --- hw/xbox/mcpx/apu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/xbox/mcpx/apu.c b/hw/xbox/mcpx/apu.c index e1301bc07cd..5ca3453c6ac 100644 --- a/hw/xbox/mcpx/apu.c +++ b/hw/xbox/mcpx/apu.c @@ -2631,6 +2631,16 @@ void mcpx_apu_init(PCIBus *bus, int devfn, MemoryRegion *ram) exit(1); } + if (SDL_GetNumAudioDevices(0) == 0) { + SDL_QuitSubSystem(SDL_INIT_AUDIO); + + if (SDL_AudioInit("dummy") < 0) { + fprintf(stderr, "Failed to initalize 'dummy' audio device\n"); + assert(!"SDL_AudioInit failed!"); + exit(1); + } + } + SDL_AudioDeviceID sdl_audio_dev; sdl_audio_dev = SDL_OpenAudioDevice(NULL, 0, &sdl_audio_spec, NULL, 0); if (sdl_audio_dev == 0) {