SDL: Fix SDL audio in some cases
Jeffrey Pfau jeffrey@endrift.com
Wed, 19 Nov 2014 23:14:44 -0800
3 files changed,
6 insertions(+),
4 deletions(-)
M
src/gba/gba-thread.c
→
src/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.c
→
src/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.c
→
src/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) {