Skip to content

Commit

Permalink
Merge pull request #2373 from jdieter/master
Browse files Browse the repository at this point in the history
Reverts #2362 while still fixing deadlock when adding multiple Wiimotes
  • Loading branch information
skidau committed May 7, 2015
2 parents 80fe5e0 + 3fe839d commit 7b3bc9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/CPU.cpp
Expand Up @@ -150,9 +150,9 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock)
if (doLock)
{
// we can't use EnableStepping, that would causes deadlocks with both audio and video
PowerPC::Pause();
if (!Core::IsCPUThread())
m_csCpuOccupied.lock();
PowerPC::Pause();
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -829,7 +829,10 @@ void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32
// Read the Wiimote once
void Update(int _WiimoteNumber)
{
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
// Try to get a lock and return without doing anything if we fail
// This avoids deadlocks when adding a Wiimote during continuous scan
if(!g_refresh_lock.try_lock())
return;

if (g_wiimotes[_WiimoteNumber])
g_wiimotes[_WiimoteNumber]->Update();
Expand All @@ -839,6 +842,7 @@ void Update(int _WiimoteNumber)
{
Host_ConnectWiimote(_WiimoteNumber, false);
}
g_refresh_lock.unlock();
}

void StateChange(EMUSTATE_CHANGE newState)
Expand Down

0 comments on commit 7b3bc9b

Please sign in to comment.