diff --git a/CHANGES b/CHANGES index 151863e1c..c201351bc 100644 --- a/CHANGES +++ b/CHANGES @@ -44,6 +44,7 @@ Bugfixes: - GB Memory: Fix HDMA5 value after DMA completes - GB Video: Hblank IRQs should mask LYC=LY IRQs - GB Audio: Reset envelope timer when reseting sound channel + - SDL: Prevent crash on cores with no audio Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers @@ -214,6 +215,7 @@ Misc: - Wii: Add pixelated resample filter - Windows: Add native VDir support - Util: Add PRIz macro for libc versions that don't support %z + - GBA: Better debug logging if event processing breaks 0.4.1: (2016-07-11) Bugfixes: diff --git a/src/platform/sdl/sdl-audio.c b/src/platform/sdl/sdl-audio.c index 913fc99a1..b0745ba26 100644 --- a/src/platform/sdl/sdl-audio.c +++ b/src/platform/sdl/sdl-audio.c @@ -99,6 +99,10 @@ static void _mSDLAudioCallback(void* context, Uint8* data, int len) { right = audioContext->core->getAudioChannel(audioContext->core, 1); clockRate = audioContext->core->frequency(audioContext->core); } + if (!left) { + memset(data, 0, len); + return; + } double fauxClock = 1; if (audioContext->sync) { if (audioContext->sync->fpsTarget > 0) { @@ -107,14 +111,16 @@ static void _mSDLAudioCallback(void* context, Uint8* data, int len) { mCoreSyncLockAudio(audioContext->sync); } blip_set_rates(left, clockRate, audioContext->obtainedSpec.freq * fauxClock); - blip_set_rates(right, clockRate, audioContext->obtainedSpec.freq * fauxClock); + if (right) { + blip_set_rates(right, clockRate, audioContext->obtainedSpec.freq * fauxClock); + } len /= 2 * audioContext->obtainedSpec.channels; int available = blip_samples_avail(left); if (available > len) { available = len; } blip_read_samples(left, (short*) data, available, audioContext->obtainedSpec.channels == 2); - if (audioContext->obtainedSpec.channels == 2) { + if (audioContext->obtainedSpec.channels == 2 && right) { blip_read_samples(right, ((short*) data) + 1, available, 1); }