GBA Audio: Fix crash in audio subsampling if timing lockstep breaks

This commit is contained in:
Vicki Pfau 2024-06-25 04:08:47 -07:00
parent e0b0e45821
commit b205537558
2 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ Emulation fixes:
- 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 Audio: Fix crash in audio subsampling if timing lockstep breaks
- 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

@ -268,6 +268,9 @@ void GBAAudioWriteSOUNDBIAS(struct GBAAudio* audio, uint16_t value) {
if (oldSampleInterval != audio->sampleInterval) {
timestamp -= audio->lastSample;
audio->sampleIndex = timestamp >> (9 - GBARegisterSOUNDBIASGetResolution(value));
if (audio->sampleIndex < 0 || audio->sampleIndex >= GBA_MAX_SAMPLES) {
audio->sampleIndex = 0;
}
if (audio->p->stream && audio->p->stream->audioRateChanged) {
audio->p->stream->audioRateChanged(audio->p->stream, GBA_ARM7TDMI_FREQUENCY / audio->sampleInterval);
}