all repos — mgba @ d8b745252619874b866f895291ea9d9838ff6367

mGBA Game Boy Advance Emulator

SDL: Fix SDL audio in some cases
Jeffrey Pfau jeffrey@endrift.com
Wed, 19 Nov 2014 23:14:44 -0800
commit

d8b745252619874b866f895291ea9d9838ff6367

parent

51896cdcd63c16f1fcbd85b68846cd118435809d

3 files changed, 6 insertions(+), 4 deletions(-)

jump to
M src/gba/gba-thread.csrc/gba/gba-thread.c

@@ -117,8 +117,8 @@

GBACreate(&gba); ARMSetComponents(&cpu, &gba.d, numComponents, components); ARMInit(&cpu); - threadContext->gba = &gba; gba.sync = &threadContext->sync; + threadContext->gba = &gba; gba.logLevel = threadContext->logLevel; #ifdef USE_PTHREADS pthread_setspecific(_contextKey, threadContext);
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -25,8 +25,6 @@ #define PORT "sdl"

static bool _GBASDLInit(struct SDLSoftwareRenderer* renderer); static void _GBASDLDeinit(struct SDLSoftwareRenderer* renderer); -static void _GBASDLStart(struct GBAThread* context); -static void _GBASDLClean(struct GBAThread* context); int main(int argc, char** argv) { struct SDLSoftwareRenderer renderer;
M src/platform/sdl/sdl-audio.csrc/platform/sdl/sdl-audio.c

@@ -53,11 +53,15 @@ }

static void _GBASDLAudioCallback(void* context, Uint8* data, int len) { struct GBASDLAudio* audioContext = context; - if (!context || !audioContext->thread) { + if (!context || !audioContext->thread || !audioContext->thread->gba) { memset(data, 0, len); return; } audioContext->ratio = GBAAudioCalculateRatio(&audioContext->thread->gba->audio, audioContext->thread->fpsTarget, audioContext->obtainedSpec.freq); + if (audioContext->ratio == INFINITY) { + memset(data, 0, len); + return; + } struct GBAStereoSample* ssamples = (struct GBAStereoSample*) data; len /= 2 * audioContext->obtainedSpec.channels; if (audioContext->obtainedSpec.channels == 2) {