Android: nativeQuit for SDLActivity thread
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 10 Jan 2019 15:43:07 +0100
changeset 12518f20cacda9d6d
parent 12517 608b59e27e10
child 12519 4476dd3fec4a
Android: nativeQuit for SDLActivity thread

- destroy Android_ActivityMutex
- display any SDL error message that may have occured in this thread,
since SDL_GetError() is thread specific, and user has no access to it.
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
src/core/android/SDL_android.c
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu Jan 10 15:35:46 2019 +0100
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu Jan 10 15:43:07 2019 +0100
     1.3 @@ -405,6 +405,8 @@
     1.4              }
     1.5          }
     1.6  
     1.7 +        SDLActivity.nativeQuit();
     1.8 +
     1.9          super.onDestroy();
    1.10      }
    1.11  
    1.12 @@ -727,6 +729,7 @@
    1.13      public static native int nativeRunMain(String library, String function, Object arguments);
    1.14      public static native void nativeLowMemory();
    1.15      public static native void nativeSendQuit();
    1.16 +    public static native void nativeQuit();
    1.17      public static native void nativePause();
    1.18      public static native void nativeResume();
    1.19      public static native void onNativeDropFile(String filename);
     2.1 --- a/src/core/android/SDL_android.c	Thu Jan 10 15:35:46 2019 +0100
     2.2 +++ b/src/core/android/SDL_android.c	Thu Jan 10 15:43:07 2019 +0100
     2.3 @@ -125,6 +125,9 @@
     2.4  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
     2.5          JNIEnv *env, jclass cls);
     2.6  
     2.7 +JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
     2.8 +        JNIEnv *env, jclass cls);
     2.9 +
    2.10  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
    2.11          JNIEnv *env, jclass cls);
    2.12  
    2.13 @@ -833,6 +836,25 @@
    2.14      SDL_SemPost(Android_ResumeSem);
    2.15  }
    2.16  
    2.17 +/* Activity ends */
    2.18 +JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
    2.19 +                                    JNIEnv *env, jclass cls)
    2.20 +{
    2.21 +    const char *str;
    2.22 +
    2.23 +    if (Android_ActivityMutex) {
    2.24 +        SDL_DestroyMutex(Android_ActivityMutex);
    2.25 +        Android_ActivityMutex = NULL;
    2.26 +    }
    2.27 +
    2.28 +    str = SDL_GetError();
    2.29 +    if (str && str[0]) {
    2.30 +        __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDLActivity thread ends (error=%s)", str);
    2.31 +    } else {
    2.32 +        __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDLActivity thread ends");
    2.33 +    }
    2.34 +}
    2.35 +
    2.36  /* Pause */
    2.37  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
    2.38                                      JNIEnv *env, jclass cls)