From c39eeb963895a2eb05e17bc28c357f7d3f4ce815 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 2 Oct 2018 12:40:26 -0700 Subject: Don't try to get the JNIEnv on Android It's currently not used. More stuff is needed anyway which may need a different approach. --- Alc/ALc.c | 69 --------------------------------------------------------------- 1 file changed, 69 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index de6a2b75..47351b99 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -1165,75 +1165,6 @@ static void alc_initconfig(void) } #define DO_INITCONFIG() alcall_once(&alc_config_once, alc_initconfig) -#ifdef __ANDROID__ -#include - -static JavaVM *gJavaVM; -static pthread_key_t gJVMThreadKey; - -static void CleanupJNIEnv(void* UNUSED(ptr)) -{ - JCALL0(gJavaVM,DetachCurrentThread)(); -} - -void *Android_GetJNIEnv(void) -{ - if(!gJavaVM) - { - WARN("gJavaVM is NULL!\n"); - return NULL; - } - - /* http://developer.android.com/guide/practices/jni.html - * - * All threads are Linux threads, scheduled by the kernel. They're usually - * started from managed code (using Thread.start), but they can also be - * created elsewhere and then attached to the JavaVM. For example, a thread - * started with pthread_create can be attached with the JNI - * AttachCurrentThread or AttachCurrentThreadAsDaemon functions. Until a - * thread is attached, it has no JNIEnv, and cannot make JNI calls. - * Attaching a natively-created thread causes a java.lang.Thread object to - * be constructed and added to the "main" ThreadGroup, making it visible to - * the debugger. Calling AttachCurrentThread on an already-attached thread - * is a no-op. - */ - JNIEnv *env = pthread_getspecific(gJVMThreadKey); - if(!env) - { - int status = JCALL(gJavaVM,AttachCurrentThread)(&env, NULL); - if(status < 0) - { - ERR("Failed to attach current thread\n"); - return NULL; - } - pthread_setspecific(gJVMThreadKey, env); - } - return env; -} - -/* Automatically called by JNI. */ -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void* UNUSED(reserved)) -{ - void *env; - int err; - - gJavaVM = jvm; - if(JCALL(gJavaVM,GetEnv)(&env, JNI_VERSION_1_4) != JNI_OK) - { - ERR("Failed to get JNIEnv with JNI_VERSION_1_4\n"); - return JNI_ERR; - } - - /* Create gJVMThreadKey so we can keep track of the JNIEnv assigned to each - * thread. The JNIEnv *must* be detached before the thread is destroyed. - */ - if((err=pthread_key_create(&gJVMThreadKey, CleanupJNIEnv)) != 0) - ERR("pthread_key_create failed: %d\n", err); - pthread_setspecific(gJVMThreadKey, env); - return JNI_VERSION_1_4; -} -#endif - /************************************************ * Library deinitialization -- cgit v1.2.3