SDL: Prevent crash on cores with no audio

This commit is contained in:
Jeffrey Pfau 2016-06-01 19:46:16 -07:00
parent 3cf9446ba1
commit e93154fb41
2 changed files with 10 additions and 2 deletions

View File

@ -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:

View File

@ -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);
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);
}