From fdd7875051d8fa1cb0a9902bea1d67bbd2eefad7 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Tue, 15 Jun 2021 20:41:43 -0700 Subject: [PATCH] sdl: Print out SDL_GetError message when subsystem init fails --- hw/xbox/mcpx/apu.c | 5 ++++- ui/xemu-input.c | 4 ++-- ui/xemu.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/xbox/mcpx/apu.c b/hw/xbox/mcpx/apu.c index 3f1ef86800..8b56401562 100644 --- a/hw/xbox/mcpx/apu.c +++ b/hw/xbox/mcpx/apu.c @@ -2601,7 +2601,10 @@ void mcpx_apu_init(PCIBus *bus, int devfn, MemoryRegion *ram) .userdata = d, }; - assert(SDL_Init(SDL_INIT_AUDIO) >= 0); + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + fprintf(stderr, "Failed to initialize SDL audio subsystem: %s\n", SDL_GetError()); + exit(1); + } SDL_AudioDeviceID sdl_audio_dev; sdl_audio_dev = SDL_OpenAudioDevice(NULL, 0, &sdl_audio_spec, NULL, 0); diff --git a/ui/xemu-input.c b/ui/xemu-input.c index 7577b72d45..237a400aac 100644 --- a/ui/xemu-input.c +++ b/ui/xemu-input.c @@ -63,12 +63,12 @@ void xemu_input_init(void) SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0) { - fprintf(stderr, "Failed to initialize SDL gamecontroller subsystem\n"); + fprintf(stderr, "Failed to initialize SDL gamecontroller subsystem: %s\n", SDL_GetError()); exit(1); } if (SDL_Init(SDL_INIT_HAPTIC) < 0) { - fprintf(stderr, "Failed to initialize SDL haptic subsystem\n"); + fprintf(stderr, "Failed to initialize SDL haptic subsystem: %s\n", SDL_GetError()); exit(1); } diff --git a/ui/xemu.c b/ui/xemu.c index 0da047a1f2..efe769bd03 100644 --- a/ui/xemu.c +++ b/ui/xemu.c @@ -809,7 +809,7 @@ static void sdl2_display_very_early_init(DisplayOptions *o) #endif if (SDL_Init(SDL_INIT_VIDEO)) { - fprintf(stderr, "Could not initialize SDL(%s) - exiting\n", + fprintf(stderr, "Failed to initialize SDL video subsystem: %s\n", SDL_GetError()); exit(1); }