src/core/android/SDL_android.c
changeset 12564 04ec6bb43c4e
parent 12563 db549862a09a
child 12625 e58468e48179
equal deleted inserted replaced
12563:db549862a09a 12564:04ec6bb43c4e
   329 JNIEnv* Android_JNI_GetEnv(void)
   329 JNIEnv* Android_JNI_GetEnv(void)
   330 {
   330 {
   331     /* Get JNIEnv from the Thread local storage */
   331     /* Get JNIEnv from the Thread local storage */
   332     JNIEnv *env = pthread_getspecific(mThreadKey);
   332     JNIEnv *env = pthread_getspecific(mThreadKey);
   333     if (env == NULL) {
   333     if (env == NULL) {
   334         /* If it fails, try to attach ! (e.g the thread isn't * created with SDL_CreateThread() */
   334         /* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */
   335         int status;
   335         int status;
   336 
   336 
   337         /* There should be a JVM */
   337         /* There should be a JVM */
   338         if (mJavaVM == NULL) {
   338         if (mJavaVM == NULL) {
   339             __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
   339             __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
   340             return 0;
   340             return NULL;
   341         }
   341         }
   342 
   342 
   343         /* Attach the current thread to the JVM and get a JNIEnv.
   343         /* Attach the current thread to the JVM and get a JNIEnv.
   344          * It will be detached by pthread_create destructor 'Android_JNI_ThreadDestroyed' */
   344          * It will be detached by pthread_create destructor 'Android_JNI_ThreadDestroyed' */
   345         status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL);
   345         status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL);