summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/GCAdapter_Android.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/GCAdapter_Android.cpp')
-rw-r--r--Source/Core/InputCommon/GCAdapter_Android.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/Source/Core/InputCommon/GCAdapter_Android.cpp b/Source/Core/InputCommon/GCAdapter_Android.cpp
index 176b8b3192..90a83c20eb 100644
--- a/Source/Core/InputCommon/GCAdapter_Android.cpp
+++ b/Source/Core/InputCommon/GCAdapter_Android.cpp
@@ -66,8 +66,7 @@ static void ScanThreadFunc()
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread started");
- JNIEnv* env;
- IDCache::GetJavaVM()->AttachCurrentThread(&env, NULL);
+ JNIEnv* env = IDCache::GetEnvForThread();
jmethodID queryadapter_func = env->GetStaticMethodID(s_adapter_class, "QueryAdapter", "()Z");
@@ -78,7 +77,6 @@ static void ScanThreadFunc()
Setup();
Common::SleepCurrentThread(1000);
}
- IDCache::GetJavaVM()->DetachCurrentThread();
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread stopped");
}
@@ -88,8 +86,7 @@ static void Write()
Common::SetCurrentThreadName("GC Adapter Write Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter write thread started");
- JNIEnv* env;
- IDCache::GetJavaVM()->AttachCurrentThread(&env, NULL);
+ JNIEnv* env = IDCache::GetEnvForThread();
jmethodID output_func = env->GetStaticMethodID(s_adapter_class, "Output", "([B)I");
while (s_write_adapter_thread_running.IsSet())
@@ -119,8 +116,6 @@ static void Write()
Common::YieldCPU();
}
- IDCache::GetJavaVM()->DetachCurrentThread();
-
NOTICE_LOG(SERIALINTERFACE, "GC Adapter write thread stopped");
}
@@ -130,8 +125,7 @@ static void Read()
NOTICE_LOG(SERIALINTERFACE, "GC Adapter read thread started");
bool first_read = true;
- JNIEnv* env;
- IDCache::GetJavaVM()->AttachCurrentThread(&env, NULL);
+ JNIEnv* env = IDCache::GetEnvForThread();
jfieldID payload_field = env->GetStaticFieldID(s_adapter_class, "controller_payload", "[B");
jobject payload_object = env->GetStaticObjectField(s_adapter_class, payload_field);
@@ -185,8 +179,6 @@ static void Read()
s_fd = 0;
s_detected = false;
- IDCache::GetJavaVM()->DetachCurrentThread();
-
NOTICE_LOG(SERIALINTERFACE, "GC Adapter read thread stopped");
}
@@ -203,8 +195,7 @@ void Init()
s_last_init = CoreTiming::GetTicks();
}
- JNIEnv* env;
- IDCache::GetJavaVM()->AttachCurrentThread(&env, NULL);
+ JNIEnv* env = IDCache::GetEnvForThread();
jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Java_GCAdapter");
s_adapter_class = reinterpret_cast<jclass>(env->NewGlobalRef(adapter_class));