mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Synchronize DVDInterface::ChangeDisc with the CPU thread properly.
This addresses a bit of thread unsafety mentioned in a comment, and fixes a 'ScheduleEvent_Threadsafe from main thread' message. To make this work nicely, make PauseAndLock call DeclareAsCPUThread - i.e. while you have the CPU thread locked, you can consider yourself the CPU thread.
This commit is contained in:
@ -149,13 +149,22 @@ void Break()
|
||||
|
||||
bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
|
||||
{
|
||||
static bool s_have_fake_cpu_thread;
|
||||
bool wasUnpaused = !IsStepping();
|
||||
if (do_lock)
|
||||
{
|
||||
// we can't use EnableStepping, that would causes deadlocks with both audio and video
|
||||
PowerPC::Pause();
|
||||
if (!Core::IsCPUThread())
|
||||
{
|
||||
m_csCpuOccupied.lock();
|
||||
s_have_fake_cpu_thread = true;
|
||||
Core::DeclareAsCPUThread();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_have_fake_cpu_thread = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -165,8 +174,12 @@ bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
|
||||
m_StepEvent.Set();
|
||||
}
|
||||
|
||||
if (!Core::IsCPUThread())
|
||||
if (s_have_fake_cpu_thread)
|
||||
{
|
||||
Core::UndeclareAsCPUThread();
|
||||
m_csCpuOccupied.unlock();
|
||||
s_have_fake_cpu_thread = false;
|
||||
}
|
||||
}
|
||||
return wasUnpaused;
|
||||
}
|
||||
|
Reference in New Issue
Block a user