try to fix audio pops on game loading on GX

This commit is contained in:
Toad King 2014-10-12 19:22:43 -05:00
parent 4766675fa5
commit d3047e6f59

View File

@ -57,11 +57,14 @@ typedef struct
} gx_audio_t;
static volatile gx_audio_t *gx_audio_data;
static volatile bool stop_audio;
static void dma_callback(void)
{
gx_audio_t *wa = (gx_audio_t*)gx_audio_data;
if (!stop_audio)
{
/* Erase last chunk to avoid repeating audio. */
memset(wa->data[wa->dma_busy], 0, CHUNK_SIZE);
@ -69,9 +72,11 @@ static void dma_callback(void)
wa->dma_next = (wa->dma_next + 1) & (BLOCKS - 1);
DCFlushRange(wa->data[wa->dma_next], CHUNK_SIZE);
AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE);
OSSignalCond(wa->cond);
}
}
static void *gx_audio_init(const char *device,
@ -103,6 +108,7 @@ static void *gx_audio_init(const char *device,
wa->dma_write = BLOCKS - 1;
DCFlushRange(wa->data, sizeof(wa->data));
stop_audio = false;
AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE);
AIStartDMA();
@ -201,6 +207,7 @@ static void gx_audio_free(void *data)
if (!wa)
return;
stop_audio = true;
AIStopDMA();
AIRegisterDMACallback(NULL);