From 9142b5bd766e924e92f0aab1c0d9a34c5170a931 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 24 Jan 2013 18:31:53 -0600 Subject: [PATCH] Added appropriate audio thread pausing to the GUI layer. --- src/dac.cpp | 9 +++++++++ src/dac.h | 1 + src/gpu.cpp | 1 + src/gui/mainwin.cpp | 21 +++++++++++++-------- src/log.h | 6 +++++- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/dac.cpp b/src/dac.cpp index 7cc3740..6a60906 100644 --- a/src/dac.cpp +++ b/src/dac.cpp @@ -138,6 +138,15 @@ void DACReset(void) } +// +// Pause/unpause the SDL audio thread +// +void DACPauseAudioThread(bool state/*= true*/) +{ + SDL_PauseAudio(state); +} + + // // Close down the SDL sound subsystem // diff --git a/src/dac.h b/src/dac.h index d0c5720..1cfc8b1 100644 --- a/src/dac.h +++ b/src/dac.h @@ -9,6 +9,7 @@ void DACInit(void); void DACReset(void); +void DACPauseAudioThread(bool state = true); void DACDone(void); //int GetCalculatedFrequency(void); diff --git a/src/gpu.cpp b/src/gpu.cpp index 02fa112..09a664d 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -780,6 +780,7 @@ WriteLog("GPU: %s setting GPU PC to %08X %s\n", whoName[who], gpu_pc, (GPU_RUNNI { //WriteLog("asked to perform a single step (single step is %senabled)\n",(data&0x8)?"":"not "); } + gpu_control = (gpu_control & 0xF7C0) | (data & (~0xF7C0)); // if gpu wasn't running but is now running, execute a few cycles diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 04ae3ba..28d022b 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -616,17 +616,17 @@ void MainWin::Timer(void) // Some machines can't handle this, so we give them the option to disable it. :-) if (!plzDontKillMyComputer) { - // Random hash & trash - // We try to simulate an untuned tank circuit here... :-) - for(uint32_t x=0; xrasterWidth; x++) - { - for(uint32_t y=0; yrasterHeight; y++) + // Random hash & trash + // We try to simulate an untuned tank circuit here... :-) + for(uint32_t x=0; xrasterWidth; x++) { - videoWidget->buffer[(y * videoWidget->textureWidth) + x] - = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24; + for(uint32_t y=0; yrasterHeight; y++) + { + videoWidget->buffer[(y * videoWidget->textureWidth) + x] + = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24; + } } } - } } else { @@ -655,6 +655,7 @@ void MainWin::TogglePowerState(void) showUntunedTankCircuit = true; // This is just in case the ROM we were playing was in a narrow or wide field mode, // so the untuned tank sim doesn't look wrong. :-) + DACPauseAudioThread(); TOMReset(); } else @@ -680,6 +681,7 @@ void MainWin::TogglePowerState(void) WriteLog("GUI: Resetting Jaguar...\n"); JaguarReset(); + DACPauseAudioThread(false); } } @@ -700,6 +702,9 @@ void MainWin::ToggleRunState(void) videoWidget->updateGL(); } + + // Pause/unpause any running/non-running threads... + DACPauseAudioThread(!running); } diff --git a/src/log.h b/src/log.h index 0bf9e09..c406bf8 100644 --- a/src/log.h +++ b/src/log.h @@ -1,5 +1,5 @@ // -// LOG.H +// log.h: Logfile support // #ifndef __LOG_H__ @@ -20,4 +20,8 @@ void WriteLog(const char * text, ...); } #endif +// Some useful defines... :-) +//#define GPU_DEBUG +//#define LOG_BLITS + #endif // __LOG_H__ -- 2.37.2