From 35cec4858fe846ec8ef5937160505764a28c983b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 4 Apr 2015 22:07:46 -0700 Subject: [PATCH] GBA Audio: FIFOs should not poll DMAs that are not scheduled for audio --- CHANGES | 1 + src/gba/audio.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 53f59752d..e7c01ea62 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Bugfixes: - All: Fix sanitize-deb script not cleaning up after itself - Qt: Fix Display object leak when closing a window - Qt: Fix .deb dependencies + - GBA Audio: FIFOs should not poll DMAs that are not scheduled for audio 0.2.0: (2015-04-03) Features: diff --git a/src/gba/audio.c b/src/gba/audio.c index dce744a45..974132801 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -514,11 +514,15 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) { GBALog(audio->p, GBA_LOG_ERROR, "Bad FIFO write to address 0x%03x", fifoId); return; } - if (CircleBufferSize(&channel->fifo) <= 4 * sizeof(int32_t)) { + if (CircleBufferSize(&channel->fifo) <= 4 * sizeof(int32_t) && channel->dmaSource > 0) { struct GBADMA* dma = &audio->p->memory.dma[channel->dmaSource]; - dma->nextCount = 4; - dma->nextEvent = 0; - GBAMemoryUpdateDMAs(audio->p, -cycles); + if (GBADMARegisterGetTiming(dma->reg) == DMA_TIMING_CUSTOM) { + dma->nextCount = 4; + dma->nextEvent = 0; + GBAMemoryUpdateDMAs(audio->p, -cycles); + } else { + channel->dmaSource = 0; + } } CircleBufferRead8(&channel->fifo, &channel->sample); }