mirror of https://github.com/mgba-emu/mgba.git
SDL: Fix race condition with audio thread when starting
This commit is contained in:
parent
4a38f9b979
commit
232e67f529
1
CHANGES
1
CHANGES
|
@ -32,6 +32,7 @@ Bugfixes:
|
|||
- GBA Video: Fix wrong palette on 256-color sprites in OBJWIN
|
||||
- Windows: Fix VDir.rewind
|
||||
- SDL: Fix game crash check
|
||||
- SDL: Fix race condition with audio thread when starting
|
||||
Misc:
|
||||
- SDL: Remove scancode key input
|
||||
- GBA Video: Clean up unused timers
|
||||
|
|
|
@ -185,29 +185,31 @@ int mSDLRun(struct mSDLRenderer* renderer, struct mArguments* args) {
|
|||
renderer->audio.samples = renderer->core->opts.audioBuffers;
|
||||
renderer->audio.sampleRate = 44100;
|
||||
|
||||
bool didFail = !mSDLInitAudio(&renderer->audio, &thread);
|
||||
bool didFail = !mCoreThreadStart(&thread);
|
||||
if (!didFail) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
mSDLSetScreensaverSuspendable(&renderer->events, renderer->core->opts.suspendScreensaver);
|
||||
mSDLSuspendScreensaver(&renderer->events);
|
||||
#endif
|
||||
if (mCoreThreadStart(&thread)) {
|
||||
if (mSDLInitAudio(&renderer->audio, &thread)) {
|
||||
renderer->runloop(renderer, &thread);
|
||||
mSDLPauseAudio(&renderer->audio);
|
||||
if (mCoreThreadHasCrashed(&thread)) {
|
||||
didFail = true;
|
||||
printf("The game crashed!\n");
|
||||
}
|
||||
mCoreThreadJoin(&thread);
|
||||
} else {
|
||||
didFail = true;
|
||||
printf("Could not run game. Are you sure the file exists and is a compatible game?\n");
|
||||
printf("Could not initialize audio.\n");
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
mSDLResumeScreensaver(&renderer->events);
|
||||
mSDLSetScreensaverSuspendable(&renderer->events, false);
|
||||
#endif
|
||||
|
||||
mCoreThreadJoin(&thread);
|
||||
} else {
|
||||
printf("Could not run game. Are you sure the file exists and is a compatible game?\n");
|
||||
}
|
||||
renderer->core->unloadROM(renderer->core);
|
||||
return didFail;
|
||||
|
|
Loading…
Reference in New Issue