GBA: Cap audio FIFO read size during deserialization

This commit is contained in:
Jeffrey Pfau 2015-06-01 00:33:16 -07:00
parent 1157ab06d2
commit ab6eac53ee
3 changed files with 8 additions and 3 deletions

View File

@ -33,6 +33,7 @@ Bugfixes:
- ARM7: Fix Thumb MUL timing - ARM7: Fix Thumb MUL timing
- Qt: Cap the maximum number of multiplayer windows - Qt: Cap the maximum number of multiplayer windows
- Qt: Fix maximum year in sensor override - Qt: Fix maximum year in sensor override
- GBA: Cap audio FIFO read size during deserialization
Misc: Misc:
- Qt: Handle saving input settings better - Qt: Handle saving input settings better
- Debugger: Free watchpoints in addition to breakpoints - Debugger: Free watchpoints in addition to breakpoints

View File

@ -904,8 +904,12 @@ void GBAAudioDeserialize(struct GBAAudio* audio, const struct GBASerializedState
CircleBufferClear(&audio->chA.fifo); CircleBufferClear(&audio->chA.fifo);
CircleBufferClear(&audio->chB.fifo); CircleBufferClear(&audio->chB.fifo);
int i; size_t fifoSize = state->audio.fifoSize;
for (i = 0; i < state->audio.fifoSize; ++i) { if (state->audio.fifoSize > CircleBufferCapacity(&audio->chA.fifo)) {
fifoSize = CircleBufferCapacity(&audio->chA.fifo);
}
size_t i;
for (i = 0; i < fifoSize; ++i) {
CircleBufferWrite8(&audio->chA.fifo, state->audio.fifoA[i]); CircleBufferWrite8(&audio->chA.fifo, state->audio.fifoA[i]);
CircleBufferWrite8(&audio->chB.fifo, state->audio.fifoB[i]); CircleBufferWrite8(&audio->chB.fifo, state->audio.fifoB[i]);
} }

View File

@ -231,7 +231,7 @@ struct GBASerializedState {
int32_t nextEvent; int32_t nextEvent;
int32_t eventDiff; int32_t eventDiff;
int32_t nextSample; int32_t nextSample;
int32_t fifoSize; uint32_t fifoSize;
unsigned ch1Volume : 4; unsigned ch1Volume : 4;
unsigned ch1Dead : 1; unsigned ch1Dead : 1;
unsigned ch1Hi : 1; unsigned ch1Hi : 1;