mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-09 21:40:10 +00:00
ControllerInterface: Add synchronisation
Since we may have to add/access devices from different threads, this adds synchronisation to anything that touches m_devices.
This commit is contained in:
parent
fd29e5c4cc
commit
d3e2ae35ff
@ -104,6 +104,8 @@ void ControllerInterface::Shutdown()
|
|||||||
if (!m_is_init)
|
if (!m_is_init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||||
|
|
||||||
for (ciface::Core::Device* d : m_devices)
|
for (ciface::Core::Device* d : m_devices)
|
||||||
{
|
{
|
||||||
// Set outputs to ZERO before destroying device
|
// Set outputs to ZERO before destroying device
|
||||||
@ -141,6 +143,7 @@ void ControllerInterface::Shutdown()
|
|||||||
|
|
||||||
void ControllerInterface::AddDevice(ciface::Core::Device* device)
|
void ControllerInterface::AddDevice(ciface::Core::Device* device)
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||||
m_devices.push_back(device);
|
m_devices.push_back(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +154,7 @@ void ControllerInterface::AddDevice(ciface::Core::Device* device)
|
|||||||
//
|
//
|
||||||
void ControllerInterface::UpdateInput()
|
void ControllerInterface::UpdateInput()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||||
for (ciface::Core::Device* d : m_devices)
|
for (ciface::Core::Device* d : m_devices)
|
||||||
d->UpdateInput();
|
d->UpdateInput();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ public:
|
|||||||
Device* FindDevice(const DeviceQualifier& devq) const;
|
Device* FindDevice(const DeviceQualifier& devq) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::mutex m_devices_mutex;
|
||||||
std::vector<Device*> m_devices;
|
std::vector<Device*> m_devices;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user