GBA Audio: Fix crash if audio FIFOs and timers get out of sync

This commit is contained in:
Vicki Pfau 2024-06-25 03:43:22 -07:00
parent 1a3873da67
commit a4c2571d98
2 changed files with 4 additions and 0 deletions

View File

@ -23,6 +23,7 @@ Other fixes:
- Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963)
- Debugger: Fix writing to specific segment in command-line debugger
- GB: Fix uninitialized save data when loading undersized temporary saves
- GBA Audio: Fix crash if audio FIFOs and timers get out of sync
- GBA Memory: Let raw access read high MMIO addresses
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
- Qt: Fix potential crash when configuring shortcuts

View File

@ -321,6 +321,9 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) {
int bits = 2 << GBARegisterSOUNDBIASGetResolution(audio->soundbias);
until += 1 << (9 - GBARegisterSOUNDBIASGetResolution(audio->soundbias));
until >>= 9 - GBARegisterSOUNDBIASGetResolution(audio->soundbias);
if (UNLIKELY(bits < until)) {
until = bits;
}
int i;
for (i = bits - until; i < bits; ++i) {
channel->samples[i] = channel->internalSample;