From 76160276848bd2bbfa6be5335c9cd374ead49a58 Mon Sep 17 00:00:00 2001 From: nyanpasu64 Date: Sun, 27 Mar 2022 22:27:44 -0700 Subject: [PATCH] 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(). --- Source/Core/InputCommon/GCAdapter_Android.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/GCAdapter_Android.cpp b/Source/Core/InputCommon/GCAdapter_Android.cpp index 1e58733236..b129eaaf0f 100644 --- a/Source/Core/InputCommon/GCAdapter_Android.cpp +++ b/Source/Core/InputCommon/GCAdapter_Android.cpp @@ -41,7 +41,7 @@ static u8 s_controller_rumble[4]; // Input handling static std::mutex s_read_mutex; static std::array s_controller_payload; -static std::atomic s_controller_payload_size{0}; +static int s_controller_payload_size{0}; // Output handling static std::mutex s_write_mutex; @@ -164,7 +164,7 @@ static void Read() { std::lock_guard lk(s_read_mutex); 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); @@ -284,7 +284,7 @@ GCPadStatus Input(int chan) { std::lock_guard lk(s_read_mutex); controller_payload_copy = s_controller_payload; - payload_size = s_controller_payload_size.load(); + payload_size = s_controller_payload_size; } GCPadStatus pad = {};