X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdac.cpp;h=990a7248b5a7c3fb4ec7152d94d0466d89e288a5;hb=b74298f2a4540168f8e4a2bbc9fc6fdc7f4afa57;hp=6a43cff0b54b676d525219dee8a8db486b0be8a8;hpb=2a28fa007da024402b00c2e341afaa9609ac1273;p=virtualjaguar diff --git a/src/dac.cpp b/src/dac.cpp index 6a43cff..990a724 100644 --- a/src/dac.cpp +++ b/src/dac.cpp @@ -4,6 +4,13 @@ // Originally by David Raingeard // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS) // Rewritten by James L. Hammons +// (C) 2010 Underground Software +// +// JLH = James L. Hammons +// +// Who When What +// --- ---------- ------------------------------------------------------------- +// JLH 01/16/2010 Created this log ;-) // // Need to set up defaults that the BIOS sets for the SSI here in DACInit()... !!! FIX !!! @@ -22,10 +29,11 @@ #include "dac.h" #include "SDL.h" -#include "gui.h" +//#include "gui.h" #include "jaguar.h" #include "log.h" #include "m68k.h" +//#include "memory.h" #include "settings.h" //#define DEBUG_DAC @@ -43,13 +51,13 @@ // Global variables -uint16 lrxd, rrxd; // I2S ports (into Jaguar) +//uint16 lrxd, rrxd; // I2S ports (into Jaguar) // Local variables 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. @@ -68,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"); @@ -174,7 +190,7 @@ if (numLeftSamplesReady == 0 || numRightSamplesReady == 0) } // -// Calculate the frequency of SCLK * 32 using the divider +// Calculate the freq9uency of SCLK * 32 using the divider // int GetCalculatedFrequency(void) { @@ -199,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] @@ -222,7 +240,8 @@ WriteLog("Tail=%X, Head=%X", ltail, lhead); WriteLog("From while: Tail=%X, Head=%X", (LeftFIFOTailPtr + 2) & (BUFFER_SIZE - 1), LeftFIFOHeadPtr); // LogDone(); // exit(0); - GUICrashGracefully("Stuck in left DAC spinlock!"); +#warning "Reimplement GUICrashGracefully!" +// GUICrashGracefully("Stuck in left DAC spinlock!"); return; } }//*/ @@ -237,6 +256,8 @@ WriteLog("Tail=%X, Head=%X", ltail, lhead); } else if (offset == RTXD + 2) { + if (!SDLSoundInitialized) + return; /* Here's what's happening now: @@ -313,7 +334,8 @@ WriteLog("Tail=%X, Head=%X", rtail, rhead); WriteLog("From while: Tail=%X, Head=%X", (RightFIFOTailPtr + 2) & (BUFFER_SIZE - 1), RightFIFOHeadPtr); // LogDone(); // exit(0); - GUICrashGracefully("Stuck in right DAC spinlock!"); +#warning "Reimplement GUICrashGracefully!" +// GUICrashGracefully("Stuck in right DAC spinlock!"); return; } }//*/ @@ -351,7 +373,8 @@ WriteLog("Tail=%X, Head=%X", rtail, rhead); WriteLog("DAC: Failed to initialize SDL sound: %s.\nDesired freq: %u\nShutting down!\n", SDL_GetError(), desired.freq); // LogDone(); // exit(1); - GUICrashGracefully("Failed to initialize SDL sound!"); +#warning "Reimplement GUICrashGracefully!" +// GUICrashGracefully("Failed to initialize SDL sound!"); return; } }