Removed the busy-wait from DSP LLE on thread. Reduces the CPU usage in this scenario by around a third.

This commit is contained in:
skidau 2012-02-05 17:18:11 +11:00
parent c53283185d
commit 8f83a89416
1 changed files with 12 additions and 3 deletions

View File

@ -49,6 +49,9 @@ DSPLLE::DSPLLE() {
m_cycle_count = 0; m_cycle_count = 0;
} }
Common::Event dspEvent;
Common::Event ppcEvent;
void DSPLLE::DoState(PointerWrap &p) void DSPLLE::DoState(PointerWrap &p)
{ {
p.Do(g_dsp.r); p.Do(g_dsp.r);
@ -96,7 +99,10 @@ void DSPLLE::dsp_thread(DSPLLE *dsp_lle)
Common::AtomicStore(dsp_lle->m_cycle_count, 0); Common::AtomicStore(dsp_lle->m_cycle_count, 0);
} }
else else
Common::YieldCPU(); {
ppcEvent.Set();
dspEvent.Wait();
}
} }
} }
@ -138,6 +144,8 @@ void DSPLLE::DSP_StopSoundStream()
m_bIsRunning = false; m_bIsRunning = false;
if (m_bDSPThread) if (m_bDSPThread)
{ {
ppcEvent.Set();
dspEvent.Set();
m_hDSPThread.join(); m_hDSPThread.join();
} }
} }
@ -274,9 +282,10 @@ void DSPLLE::DSP_Update(int cycles)
else else
{ {
// Wait for dsp thread to complete its cycle. Note: this logic should be thought through. // 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); Common::AtomicStore(m_cycle_count, dsp_cycles);
dspEvent.Set();
} }
} }