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 832c0aed27
commit e0b0e45821
2 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Emulation fixes:
- GBA GPIO: Fix gyro read-out start (fixes mgba.io/i/3141)
- GBA SIO: Fix MULTI mode SIOCNT bit 7 writes on secondary GBAs (fixes mgba.io/i/3110)
Other fixes:
- GBA Audio: Fix crash if audio FIFOs and timers get out of sync
- GBA Memory: Let raw access read high MMIO addresses
- Qt: Fix crash when applying changes to GB I/O registers in I/O view
- Qt: Fix LCDC background priority/enable bit being mis-mapped in I/O view

View File

@ -357,6 +357,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;