From 3eebfa84fef6bd50be4a6ea664a47e13541828ce Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Wed, 22 Aug 2018 20:52:19 -0600 Subject: [PATCH] clean up audio code a little --- source/gcaudio.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/source/gcaudio.cpp b/source/gcaudio.cpp index 2202a66..ad72dc6 100644 --- a/source/gcaudio.cpp +++ b/source/gcaudio.cpp @@ -15,7 +15,8 @@ #include #include "fceusupport.h" -static u8 ConfigRequested = 0; +extern int ScreenshotRequested; +extern int ConfigRequested; static u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32); static u8 mixbuffer[16000]; static int mixhead = 0; @@ -64,15 +65,16 @@ static int MixerCollect( u8 *outbuffer, int len ) ***************************************************************************/ static void AudioSwitchBuffers() { - if ( !ConfigRequested ) - { - whichab ^= 1; + if ( !ScreenshotRequested && !ConfigRequested ) { + IsPlaying = 1; int len = MixerCollect( soundbuffer[whichab], 3840 ); DCFlushRange(soundbuffer[whichab], len); AUDIO_InitDMA((u32)soundbuffer[whichab], len); - IsPlaying = 1; + whichab ^= 1; + } + else { + IsPlaying = 0; } - else IsPlaying = 0; } /**************************************************************************** @@ -123,12 +125,6 @@ SwitchAudioMode(int mode) DSP_Halt(); AUDIO_RegisterDMACallback(AudioSwitchBuffers); #endif - memset(soundbuffer[0],0,3840); - memset(soundbuffer[1],0,3840); - DCFlushRange(soundbuffer[0],3840); - DCFlushRange(soundbuffer[1],3840); - AUDIO_InitDMA((u32)soundbuffer[whichab],3200); - AUDIO_StartDMA(); } else // menu { @@ -166,18 +162,17 @@ void PlaySound( int32 *Buffer, int count ) u16 sample; u32 *dst = (u32 *)mixbuffer; - for( i = 0; i < count; i++ ) - { + for( i = 0; i < count; i++ ) { sample = Buffer[i] & 0xffff; dst[mixhead++] = sample | ( sample << 16); - if (mixhead == 4000) + if (mixhead == 4000) { mixhead = 0; + } } // Restart Sound Processing if stopped - if (IsPlaying == 0) - { - AudioSwitchBuffers (); + if (IsPlaying == 0) { + AUDIO_StartDMA(); } }