problem: TryAcquireSRWLockExclusive requires Windows 7 :/. solution kinda: use std::recursive_mutex (CriticalSection on windows) where try_lock is used. Dolphin should work on Vista x64 again.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7313 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
3151618cb3
commit
5f87642f23
|
@ -96,8 +96,8 @@ public:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifdef USE_SRWLOCKS
|
#ifdef USE_SRWLOCKS
|
||||||
SleepConditionVariableSRW(&m_handle, lock.mutex()->native_handle(), INFINITE, 0);
|
SleepConditionVariableSRW(&m_handle, lock.mutex()->native_handle(), INFINITE, 0);
|
||||||
#elif USE_CONDITION_VARIABLES
|
#elif defined(USE_CONDITION_VARIABLES)
|
||||||
SleepConditionVariableCS(m_handle, lock.mutex()->native_handle(), INFINITE);
|
SleepConditionVariableCS(&m_handle, lock.mutex()->native_handle(), INFINITE);
|
||||||
#else
|
#else
|
||||||
// TODO: broken, the unlock and wait need to be atomic
|
// TODO: broken, the unlock and wait need to be atomic
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -157,14 +157,15 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool try_lock()
|
// TryAcquireSRWLockExclusive requires Windows 7!!
|
||||||
{
|
// bool try_lock()
|
||||||
#ifdef _WIN32
|
// {
|
||||||
return (0 != TryAcquireSRWLockExclusive(&m_handle));
|
//#ifdef _WIN32
|
||||||
#else
|
// return (0 != TryAcquireSRWLockExclusive(&m_handle));
|
||||||
return !pthread_mutex_trylock(&m_handle);
|
//#else
|
||||||
#endif
|
// return !pthread_mutex_trylock(&m_handle);
|
||||||
}
|
//#endif
|
||||||
|
// }
|
||||||
|
|
||||||
native_handle_type native_handle()
|
native_handle_type native_handle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,7 @@ void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||||
// wtf is this?
|
// wtf is this?
|
||||||
_pPADStatus->button = PAD_USE_ORIGIN;
|
_pPADStatus->button = PAD_USE_ORIGIN;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||||
|
|
||||||
if (!lk.owns_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)
|
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);
|
||||||
|
|
||||||
if (lk.owns_lock())
|
if (lk.owns_lock())
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,7 @@ void Update(int _number)
|
||||||
//PanicAlert( "Wiimote_Update" );
|
//PanicAlert( "Wiimote_Update" );
|
||||||
|
|
||||||
// TODO: change this to a try_to_lock, and make it give empty input on failure
|
// TODO: change this to a try_to_lock, and make it give empty input on failure
|
||||||
std::lock_guard<std::mutex> lk(g_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(g_plugin.controls_lock);
|
||||||
|
|
||||||
static int _last_number = 4;
|
static int _last_number = 4;
|
||||||
if (_number <= _last_number)
|
if (_number <= _last_number)
|
||||||
|
|
|
@ -145,7 +145,7 @@ class CFrame : public CRenderFrame
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
Common::Event panic_event;
|
Common::Event panic_event;
|
||||||
bool bPanicResult;
|
bool bPanicResult;
|
||||||
std::mutex keystate_lock;
|
std::recursive_mutex keystate_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
|
|
|
@ -1023,7 +1023,7 @@ void CFrame::DoStop()
|
||||||
{
|
{
|
||||||
#if defined __WXGTK__
|
#if defined __WXGTK__
|
||||||
wxMutexGuiLeave();
|
wxMutexGuiLeave();
|
||||||
std::lock_guard<std::mutex> lk(keystate_lock);
|
std::lock_guard<std::recursive_mutex> lk(keystate_lock);
|
||||||
wxMutexGuiEnter();
|
wxMutexGuiEnter();
|
||||||
#endif
|
#endif
|
||||||
// Ask for confirmation in case the user accidentally clicked Stop / Escape
|
// Ask for confirmation in case the user accidentally clicked Stop / Escape
|
||||||
|
|
|
@ -278,7 +278,7 @@ void GamepadPage::ClearAll(wxCommandEvent&)
|
||||||
// no point in using the real ControllerInterface i guess
|
// no point in using the real ControllerInterface i guess
|
||||||
ControllerInterface face;
|
ControllerInterface face;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
controller->UpdateReferences(face);
|
controller->UpdateReferences(face);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -288,7 +288,7 @@ void GamepadPage::LoadDefaults(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
controller->LoadDefaults(g_controller_interface);
|
controller->LoadDefaults(g_controller_interface);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -298,7 +298,7 @@ void ControlDialog::SetControl(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
|
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -315,7 +315,7 @@ void GamepadPage::SetDevice(wxCommandEvent&)
|
||||||
controller->UpdateDefaultDevice();
|
controller->UpdateDefaultDevice();
|
||||||
|
|
||||||
// update references
|
// update references
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
control_reference->expression.clear();
|
control_reference->expression.clear();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -358,7 +358,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
||||||
|
|
||||||
control_reference->expression = STR_FROM_WXSTR(expr);
|
control_reference->expression = STR_FROM_WXSTR(expr);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -389,7 +389,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||||
|
|
||||||
control_reference->expression = STR_FROM_WXSTR(expr);
|
control_reference->expression = STR_FROM_WXSTR(expr);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
|
@ -397,13 +397,13 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||||
|
|
||||||
void GamepadPage::AdjustSetting(wxCommandEvent& event)
|
void GamepadPage::AdjustSetting(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
|
((PadSetting*)((wxControl*)event.GetEventObject())->GetClientData())->UpdateValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamepadPage::AdjustControlOption(wxCommandEvent&)
|
void GamepadPage::AdjustControlOption(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
|
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->expression.clear();
|
||||||
btn->control_reference->range = 1.0f;
|
btn->control_reference->range = 1.0f;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
// update changes
|
// update changes
|
||||||
|
@ -443,7 +443,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
||||||
// apparently, this makes the "waiting" text work on Linux
|
// apparently, this makes the "waiting" text work on Linux
|
||||||
wxTheApp->Yield();
|
wxTheApp->Yield();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||||
|
|
||||||
// if we got input, select it in the list
|
// 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
|
// apparently, this makes the "waiting" text work on Linux
|
||||||
wxTheApp->Yield();
|
wxTheApp->Yield();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||||
|
|
||||||
// if we got input, update expression and reference
|
// if we got input, update expression and reference
|
||||||
|
@ -584,7 +584,7 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
inifile.Load(fname);
|
inifile.Load(fname);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
|
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
|
||||||
controller->UpdateReferences(g_controller_interface);
|
controller->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ void InputConfigDialog::UpdateDeviceComboBox()
|
||||||
|
|
||||||
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
void GamepadPage::RefreshDevices(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(m_plugin.controls_lock);
|
std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
|
||||||
|
|
||||||
// refresh devices
|
// refresh devices
|
||||||
g_controller_interface.Shutdown();
|
g_controller_interface.Shutdown();
|
||||||
|
|
|
@ -24,7 +24,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||||
g_controller_interface.UpdateInput();
|
g_controller_interface.UpdateInput();
|
||||||
|
|
||||||
// don't want game thread updating input when we are using it here
|
// don't want game thread updating input when we are using it here
|
||||||
std::unique_lock<std::mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
|
std::unique_lock<std::recursive_mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
|
||||||
if (!lk.owns_lock())
|
if (!lk.owns_lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -595,8 +595,8 @@ bool Host_GetKeyState(int keycode)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetAsyncKeyState(keycode);
|
return GetAsyncKeyState(keycode);
|
||||||
#elif defined __WXGTK__
|
#elif defined __WXGTK__
|
||||||
std::unique_lock<std::mutex> lk(main_frame->keystate_lock, std::defer_lock);
|
std::unique_lock<std::recursive_mutex> lk(main_frame->keystate_lock, std::try_to_lock);
|
||||||
if (!lk.try_lock())
|
if (!lk.owns_lock())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool key_pressed;
|
bool key_pressed;
|
||||||
|
|
|
@ -118,7 +118,7 @@ void ControllerInterface::SetHwnd( void* const hwnd )
|
||||||
//
|
//
|
||||||
bool ControllerInterface::UpdateInput(const bool force)
|
bool ControllerInterface::UpdateInput(const bool force)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(update_lock, std::defer_lock);
|
std::unique_lock<std::recursive_mutex> lk(update_lock, std::defer_lock);
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
lk.lock();
|
lk.lock();
|
||||||
|
@ -149,7 +149,7 @@ bool ControllerInterface::UpdateInput(const bool force)
|
||||||
//
|
//
|
||||||
bool ControllerInterface::UpdateOutput(const bool force)
|
bool ControllerInterface::UpdateOutput(const bool force)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(update_lock, std::defer_lock);
|
std::unique_lock<std::recursive_mutex> lk(update_lock, std::defer_lock);
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
lk.lock();
|
lk.lock();
|
||||||
|
|
|
@ -222,7 +222,7 @@ public:
|
||||||
const std::vector<Device*>& Devices() const { return m_devices; }
|
const std::vector<Device*>& Devices() const { return m_devices; }
|
||||||
Device* FindDevice(const DeviceQualifier& devq) const;
|
Device* FindDevice(const DeviceQualifier& devq) const;
|
||||||
|
|
||||||
std::mutex update_lock;
|
std::recursive_mutex update_lock;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_is_init;
|
bool m_is_init;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
std::vector< ControllerEmu* > controllers;
|
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 ini_name;
|
||||||
const char * const gui_name;
|
const char * const gui_name;
|
||||||
|
|
Loading…
Reference in New Issue