SDL: Prevent crash on cores with no audio
Jeffrey Pfau jeffrey@endrift.com
Wed, 01 Jun 2016 19:46:16 -0700
2 files changed,
10 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -44,6 +44,7 @@ - GBA I/O: Mask off WAITCNT bits that cannot be written
- 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 @@ - VFS: Improve zip file detection
- 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:
M
src/platform/sdl/sdl-audio.c
→
src/platform/sdl/sdl-audio.c
@@ -99,6 +99,10 @@ left = audioContext->core->getAudioChannel(audioContext->core, 0);
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 @@ }
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); }