diff --git a/Source/Core/Common/Src/StdConditionVariable.h b/Source/Core/Common/Src/StdConditionVariable.h index 2781872c8f..1b81766ee0 100644 --- a/Source/Core/Common/Src/StdConditionVariable.h +++ b/Source/Core/Common/Src/StdConditionVariable.h @@ -96,8 +96,8 @@ public: #ifdef _WIN32 #ifdef USE_SRWLOCKS SleepConditionVariableSRW(&m_handle, lock.mutex()->native_handle(), INFINITE, 0); - #elif USE_CONDITION_VARIABLES - SleepConditionVariableCS(m_handle, lock.mutex()->native_handle(), INFINITE); + #elif defined(USE_CONDITION_VARIABLES) + SleepConditionVariableCS(&m_handle, lock.mutex()->native_handle(), INFINITE); #else // TODO: broken, the unlock and wait need to be atomic lock.unlock(); diff --git a/Source/Core/Common/Src/StdMutex.h b/Source/Core/Common/Src/StdMutex.h index 5a1bc6a282..0d8572eb60 100644 --- a/Source/Core/Common/Src/StdMutex.h +++ b/Source/Core/Common/Src/StdMutex.h @@ -157,14 +157,15 @@ public: #endif } - bool try_lock() - { -#ifdef _WIN32 - return (0 != TryAcquireSRWLockExclusive(&m_handle)); -#else - return !pthread_mutex_trylock(&m_handle); -#endif - } + // TryAcquireSRWLockExclusive requires Windows 7!! +// bool try_lock() +// { +//#ifdef _WIN32 +// return (0 != TryAcquireSRWLockExclusive(&m_handle)); +//#else +// return !pthread_mutex_trylock(&m_handle); +//#endif +// } native_handle_type native_handle() { diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp index 952a2ad188..8027c82db5 100644 --- a/Source/Core/Core/Src/HW/GCPad.cpp +++ b/Source/Core/Core/Src/HW/GCPad.cpp @@ -65,7 +65,7 @@ void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) // wtf is this? _pPADStatus->button = PAD_USE_ORIGIN; - std::unique_lock lk(g_plugin.controls_lock, std::try_to_lock); + std::unique_lock lk(g_plugin.controls_lock, std::try_to_lock); if (!lk.owns_lock()) { @@ -97,7 +97,7 @@ void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) // void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) { - std::unique_lock lk(g_plugin.controls_lock, std::try_to_lock); + std::unique_lock lk(g_plugin.controls_lock, std::try_to_lock); if (lk.owns_lock()) { diff --git a/Source/Core/Core/Src/HW/Wiimote.cpp b/Source/Core/Core/Src/HW/Wiimote.cpp index ca005eb8ea..fbcd577cd7 100644 --- a/Source/Core/Core/Src/HW/Wiimote.cpp +++ b/Source/Core/Core/Src/HW/Wiimote.cpp @@ -94,7 +94,7 @@ void Update(int _number) //PanicAlert( "Wiimote_Update" ); // TODO: change this to a try_to_lock, and make it give empty input on failure - std::lock_guard lk(g_plugin.controls_lock); + std::lock_guard lk(g_plugin.controls_lock); static int _last_number = 4; if (_number <= _last_number) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 4feeaf4b76..8b74dcf5f4 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -145,7 +145,7 @@ class CFrame : public CRenderFrame #ifdef __WXGTK__ Common::Event panic_event; bool bPanicResult; - std::mutex keystate_lock; + std::recursive_mutex keystate_lock; #endif #if defined(HAVE_XRANDR) && HAVE_XRANDR diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 7441fc4c62..5b55ab5bc3 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1023,7 +1023,7 @@ void CFrame::DoStop() { #if defined __WXGTK__ wxMutexGuiLeave(); - std::lock_guard lk(keystate_lock); + std::lock_guard lk(keystate_lock); wxMutexGuiEnter(); #endif // Ask for confirmation in case the user accidentally clicked Stop / Escape diff --git a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp index 9871025f6e..fb34febe69 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp @@ -278,7 +278,7 @@ void GamepadPage::ClearAll(wxCommandEvent&) // no point in using the real ControllerInterface i guess ControllerInterface face; - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); controller->UpdateReferences(face); UpdateGUI(); @@ -288,7 +288,7 @@ void GamepadPage::LoadDefaults(wxCommandEvent&) { controller->LoadDefaults(g_controller_interface); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); controller->UpdateReferences(g_controller_interface); UpdateGUI(); @@ -298,7 +298,7 @@ void ControlDialog::SetControl(wxCommandEvent&) { control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue()); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -315,7 +315,7 @@ void GamepadPage::SetDevice(wxCommandEvent&) controller->UpdateDefaultDevice(); // update references - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); controller->UpdateReferences(g_controller_interface); } @@ -334,7 +334,7 @@ void ControlDialog::ClearControl(wxCommandEvent&) { control_reference->expression.clear(); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -358,7 +358,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&) control_reference->expression = STR_FROM_WXSTR(expr); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -389,7 +389,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event) control_reference->expression = STR_FROM_WXSTR(expr); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); UpdateGUI(); @@ -397,13 +397,13 @@ void ControlDialog::AppendControl(wxCommandEvent& event) void GamepadPage::AdjustSetting(wxCommandEvent& event) { - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); ((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue(); } void GamepadPage::AdjustControlOption(wxCommandEvent&) { - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT; } @@ -423,7 +423,7 @@ void GamepadPage::ClearControl(wxCommandEvent& event) btn->control_reference->expression.clear(); btn->control_reference->range = 1.0f; - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); controller->UpdateReferences(g_controller_interface); // update changes @@ -443,7 +443,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event) // apparently, this makes the "waiting" text work on Linux wxTheApp->Yield(); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev); // if we got input, select it in the list @@ -467,7 +467,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event) // apparently, this makes the "waiting" text work on Linux wxTheApp->Yield(); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev); // if we got input, update expression and reference @@ -584,7 +584,7 @@ void GamepadPage::LoadProfile(wxCommandEvent&) IniFile inifile; inifile.Load(fname); - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); controller->LoadConfig(inifile.GetOrCreateSection("Profile")); controller->UpdateReferences(g_controller_interface); @@ -648,7 +648,7 @@ void InputConfigDialog::UpdateDeviceComboBox() void GamepadPage::RefreshDevices(wxCommandEvent&) { - std::lock_guard lk(m_plugin.controls_lock); + std::lock_guard lk(m_plugin.controls_lock); // refresh devices g_controller_interface.Shutdown(); diff --git a/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp index 6f7c83d3c2..ff5ed3b9cd 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp +++ b/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp @@ -24,7 +24,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event)) g_controller_interface.UpdateInput(); // don't want game thread updating input when we are using it here - std::unique_lock lk(g_controller_interface.update_lock, std::try_to_lock); + std::unique_lock lk(g_controller_interface.update_lock, std::try_to_lock); if (!lk.owns_lock()) return; diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index c5d20b34f5..0a05144e86 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -595,8 +595,8 @@ bool Host_GetKeyState(int keycode) #ifdef _WIN32 return GetAsyncKeyState(keycode); #elif defined __WXGTK__ - std::unique_lock lk(main_frame->keystate_lock, std::defer_lock); - if (!lk.try_lock()) + std::unique_lock lk(main_frame->keystate_lock, std::try_to_lock); + if (!lk.owns_lock()) return false; bool key_pressed; diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp index 16c633db78..77203e7ec0 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp @@ -118,7 +118,7 @@ void ControllerInterface::SetHwnd( void* const hwnd ) // bool ControllerInterface::UpdateInput(const bool force) { - std::unique_lock lk(update_lock, std::defer_lock); + std::unique_lock lk(update_lock, std::defer_lock); if (force) lk.lock(); @@ -149,7 +149,7 @@ bool ControllerInterface::UpdateInput(const bool force) // bool ControllerInterface::UpdateOutput(const bool force) { - std::unique_lock lk(update_lock, std::defer_lock); + std::unique_lock lk(update_lock, std::defer_lock); if (force) lk.lock(); diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h index 661bc832d2..2a8430913e 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h @@ -222,7 +222,7 @@ public: const std::vector& Devices() const { return m_devices; } Device* FindDevice(const DeviceQualifier& devq) const; - std::mutex update_lock; + std::recursive_mutex update_lock; private: bool m_is_init; diff --git a/Source/Core/InputCommon/Src/InputConfig.h b/Source/Core/InputCommon/Src/InputConfig.h index 190558a68a..4d25334ce7 100644 --- a/Source/Core/InputCommon/Src/InputConfig.h +++ b/Source/Core/InputCommon/Src/InputConfig.h @@ -47,7 +47,7 @@ public: std::vector< ControllerEmu* > controllers; - std::mutex controls_lock; // for changing any control references + std::recursive_mutex controls_lock; // for changing any control references const char * const ini_name; const char * const gui_name;