Remove unnecessary atomic usage in GCAdapter_Android.cpp
s_controller_write_payload_size needs to remain an atomic because Read() loads and stores without holding a mutex, Output() stores while holding s_write_mutex, and ResetRumble() stores while holding s_read_mutex! I'm pretty sure this code is wrong, specifically ResetRumble().
This commit is contained in:
parent
871b01a5d9
commit
7616027684
|
@ -41,7 +41,7 @@ static u8 s_controller_rumble[4];
|
||||||
// Input handling
|
// Input handling
|
||||||
static std::mutex s_read_mutex;
|
static std::mutex s_read_mutex;
|
||||||
static std::array<u8, 37> s_controller_payload;
|
static std::array<u8, 37> s_controller_payload;
|
||||||
static std::atomic<int> s_controller_payload_size{0};
|
static int s_controller_payload_size{0};
|
||||||
|
|
||||||
// Output handling
|
// Output handling
|
||||||
static std::mutex s_write_mutex;
|
static std::mutex s_write_mutex;
|
||||||
|
@ -164,7 +164,7 @@ static void Read()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_read_mutex);
|
std::lock_guard<std::mutex> lk(s_read_mutex);
|
||||||
std::copy(java_data, java_data + s_controller_payload.size(), s_controller_payload.begin());
|
std::copy(java_data, java_data + s_controller_payload.size(), s_controller_payload.begin());
|
||||||
s_controller_payload_size.store(read_size);
|
s_controller_payload_size = read_size;
|
||||||
}
|
}
|
||||||
env->ReleaseByteArrayElements(*java_controller_payload, java_data, 0);
|
env->ReleaseByteArrayElements(*java_controller_payload, java_data, 0);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ GCPadStatus Input(int chan)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_read_mutex);
|
std::lock_guard<std::mutex> lk(s_read_mutex);
|
||||||
controller_payload_copy = s_controller_payload;
|
controller_payload_copy = s_controller_payload;
|
||||||
payload_size = s_controller_payload_size.load();
|
payload_size = s_controller_payload_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCPadStatus pad = {};
|
GCPadStatus pad = {};
|
||||||
|
|
Loading…
Reference in New Issue