mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 12:35:27 +00:00
Avoid deadlock when adding Wiimotes (attempt #2)
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
This commit is contained in:
parent
72956d59c8
commit
3fe839d225
@ -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();
|
||||
@ -839,6 +842,7 @@ void Update(int _WiimoteNumber)
|
||||
{
|
||||
Host_ConnectWiimote(_WiimoteNumber, false);
|
||||
}
|
||||
g_refresh_lock.unlock();
|
||||
}
|
||||
|
||||
void StateChange(EMUSTATE_CHANGE newState)
|
||||
|
Loading…
x
Reference in New Issue
Block a user