all repos — mgba @ d09d0e505fc69bf2255360f0c6bb0ab9931fc9fe

mGBA Game Boy Advance Emulator

SDL: Properly check for initialization
Jeffrey Pfau jeffrey@endrift.com
Fri, 12 Jun 2015 00:53:15 -0700
commit

d09d0e505fc69bf2255360f0c6bb0ab9931fc9fe

parent

f2e298f78dbe70399ad3e1fa53655c0db418a565

2 files changed, 22 insertions(+), 17 deletions(-)

jump to
M CHANGESCHANGES

@@ -66,6 +66,7 @@ - Util: Allow disabling the threading code entirely

- GBA: SIO logging layer - Qt: Add application icon and XDG desktop files - GBA Thread: Split GBASync into a separate file + - SDL: Properly check for initialization 0.2.1: (2015-05-13) Bugfixes:
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -107,8 +107,12 @@

GBAMapOptionsToContext(&opts, &context); GBAMapArgumentsToContext(&args, &context); + bool didFail = false; + renderer.audio.samples = context.audioBuffers; - GBASDLInitAudio(&renderer.audio, &context); + if (!GBASDLInitAudio(&renderer.audio, &context)) { + didFail = true; + } renderer.player.bindings = &inputMap; GBASDLInitBindings(&inputMap);

@@ -118,28 +122,28 @@ GBASDLAttachPlayer(&renderer.events, &renderer.player);

GBASDLPlayerLoadConfig(&renderer.player, GBAConfigGetInput(&config)); context.overrides = GBAConfigGetOverrides(&config); + if (!didFail) { #if SDL_VERSION_ATLEAST(2, 0, 0) - GBASDLSetScreensaverSuspendable(&renderer.events, opts.suspendScreensaver); - GBASDLSuspendScreensaver(&renderer.events); + GBASDLSetScreensaverSuspendable(&renderer.events, opts.suspendScreensaver); + GBASDLSuspendScreensaver(&renderer.events); #endif - - int didFail = 0; - if (GBAThreadStart(&context)) { - renderer.runloop(&context, &renderer); - GBAThreadJoin(&context); - } else { - didFail = 1; - printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n"); - } + if (GBAThreadStart(&context)) { + renderer.runloop(&context, &renderer); + GBAThreadJoin(&context); + } else { + didFail = true; + printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n"); + } #if SDL_VERSION_ATLEAST(2, 0, 0) - GBASDLResumeScreensaver(&renderer.events); - GBASDLSetScreensaverSuspendable(&renderer.events, false); + GBASDLResumeScreensaver(&renderer.events); + GBASDLSetScreensaverSuspendable(&renderer.events, false); #endif - if (GBAThreadHasCrashed(&context)) { - didFail = 1; - printf("The game crashed!\n"); + if (GBAThreadHasCrashed(&context)) { + didFail = true; + printf("The game crashed!\n"); + } } freeArguments(&args); GBAConfigFreeOpts(&opts);