From c0e3db2bb4be6f92fca4b4197225594f27492596 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 22 Apr 2023 22:27:22 -0700 Subject: [PATCH] GB, GBA Audio: Clamp audio buffer size to 8192 --- src/gb/audio.c | 3 +++ src/gba/audio.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/gb/audio.c b/src/gb/audio.c index 078f93358..acd57d6d6 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -138,6 +138,9 @@ void GBAudioReset(struct GBAudio* audio) { } void GBAudioResizeBuffer(struct GBAudio* audio, size_t samples) { + if (samples > BLIP_BUFFER_SIZE / 2) { + samples = BLIP_BUFFER_SIZE / 2; + } mCoreSyncLockAudio(audio->p->sync); audio->samples = samples; blip_clear(audio->left); diff --git a/src/gba/audio.c b/src/gba/audio.c index 12c6a8754..f6e13d5c0 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -106,6 +106,9 @@ void GBAAudioDeinit(struct GBAAudio* audio) { } void GBAAudioResizeBuffer(struct GBAAudio* audio, size_t samples) { + if (samples > 0x2000) { + samples = 0x2000; + } mCoreSyncLockAudio(audio->p->sync); audio->samples = samples; blip_clear(audio->psg.left);