X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdac.cpp;h=dbb1b5842caeef2469dce21d0c46589391a4f259;hb=c1aa2a5180362f141ce43b76942952e1f6680347;hp=f37dd843ba71093171b399dd204e85b7f0f950e1;hpb=5da604521611a960140b58a2fb0f236c65610b70;p=virtualjaguar diff --git a/src/dac.cpp b/src/dac.cpp index f37dd84..dbb1b58 100644 --- a/src/dac.cpp +++ b/src/dac.cpp @@ -57,7 +57,7 @@ static uint32 LeftFIFOHeadPtr, LeftFIFOTailPtr, RightFIFOHeadPtr, RightFIFOTailPtr; static SDL_AudioSpec desired; -static bool SDLSoundInitialized = false; +static bool SDLSoundInitialized; // We can get away with using native endian here because we can tell SDL to use the native // endian when looking at the sample buffer, i.e., no need to worry about it. @@ -76,6 +76,14 @@ int GetCalculatedFrequency(void); // void DACInit(void) { + SDLSoundInitialized = false; + + if (!vjs.audioEnabled) + { + WriteLog("DAC: Host audio playback disabled.\n"); + return; + } + // memory_malloc_secure((void **)&DACBuffer, BUFFER_SIZE * sizeof(uint16), "DAC buffer"); // DACBuffer = (uint16 *)memory_malloc(BUFFER_SIZE * sizeof(uint16), "DAC buffer"); @@ -182,7 +190,7 @@ if (numLeftSamplesReady == 0 || numRightSamplesReady == 0) } // -// Calculate the freq9uency of SCLK * 32 using the divider +// Calculate the frequency of SCLK * 32 using the divider // int GetCalculatedFrequency(void) { @@ -207,6 +215,8 @@ void DACWriteWord(uint32 offset, uint16 data, uint32 who/*= UNKNOWN*/) { if (offset == LTXD + 2) { + if (!SDLSoundInitialized) + return; // Spin until buffer has been drained (for too fast processors!)... //Small problem--if Head == 0 and Tail == buffer end, then this will fail... !!! FIX !!! //[DONE] @@ -246,6 +256,8 @@ WriteLog("Tail=%X, Head=%X", ltail, lhead); } else if (offset == RTXD + 2) { + if (!SDLSoundInitialized) + return; /* Here's what's happening now: