Merge pull request #8332 from CookiePLMonster/dsp-lle-deadlock

DSPLLE: Put DSP thread in idle state when it's paused
This commit is contained in:
Anthony 2019-11-27 15:34:34 -08:00 committed by GitHub
commit e33acc07f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 13 deletions

View File

@ -98,22 +98,24 @@ void DSPLLE::DSPThread(DSPLLE* dsp_lle)
const int cycles = static_cast<int>(dsp_lle->m_cycle_count.load());
if (cycles > 0)
{
std::lock_guard<std::mutex> dsp_thread_lock(dsp_lle->m_dsp_thread_mutex);
if (g_dsp_jit)
std::unique_lock dsp_thread_lock(dsp_lle->m_dsp_thread_mutex, std::try_to_lock);
if (dsp_thread_lock)
{
DSPCore_RunCycles(cycles);
if (g_dsp_jit)
{
DSPCore_RunCycles(cycles);
}
else
{
DSP::Interpreter::RunCyclesThread(cycles);
}
dsp_lle->m_cycle_count.store(0);
continue;
}
else
{
DSP::Interpreter::RunCyclesThread(cycles);
}
dsp_lle->m_cycle_count.store(0);
}
else
{
s_ppc_event.Set();
s_dsp_event.Wait();
}
s_ppc_event.Set();
s_dsp_event.Wait();
}
}
@ -334,8 +336,16 @@ u32 DSPLLE::DSP_UpdateRate()
void DSPLLE::PauseAndLock(bool do_lock, bool unpause_on_unlock)
{
if (do_lock)
{
m_dsp_thread_mutex.lock();
}
else
{
m_dsp_thread_mutex.unlock();
// Signal the DSP thread so it can perform any outstanding work now (if any)
s_ppc_event.Wait();
s_dsp_event.Set();
}
}
} // namespace DSP::LLE