From 8f83a89416c6e13f23af19c5b329acbd271ef596 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 5 Feb 2012 17:18:11 +1100 Subject: [PATCH] Removed the busy-wait from DSP LLE on thread. Reduces the CPU usage in this scenario by around a third. --- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index 7ee5f68001..a795b4966d 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -49,6 +49,9 @@ DSPLLE::DSPLLE() { m_cycle_count = 0; } +Common::Event dspEvent; +Common::Event ppcEvent; + void DSPLLE::DoState(PointerWrap &p) { p.Do(g_dsp.r); @@ -96,7 +99,10 @@ void DSPLLE::dsp_thread(DSPLLE *dsp_lle) Common::AtomicStore(dsp_lle->m_cycle_count, 0); } else - Common::YieldCPU(); + { + ppcEvent.Set(); + dspEvent.Wait(); + } } } @@ -138,6 +144,8 @@ void DSPLLE::DSP_StopSoundStream() m_bIsRunning = false; if (m_bDSPThread) { + ppcEvent.Set(); + dspEvent.Set(); m_hDSPThread.join(); } } @@ -274,9 +282,10 @@ void DSPLLE::DSP_Update(int cycles) else { // Wait for dsp thread to complete its cycle. Note: this logic should be thought through. - while (m_cycle_count != 0) - ; + ppcEvent.Wait(); Common::AtomicStore(m_cycle_count, dsp_cycles); + dspEvent.Set(); + } }