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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 38c2cd8..5fe46e0 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -405,6 +405,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
}
+ SDLActivity.nativeQuit();
+
super.onDestroy();
}
@@ -727,6 +729,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
public static native int nativeRunMain(String library, String function, Object arguments);
public static native void nativeLowMemory();
public static native void nativeSendQuit();
+ public static native void nativeQuit();
public static native void nativePause();
public static native void nativeResume();
public static native void onNativeDropFile(String filename);
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 9811653..0a51f03 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -125,6 +125,9 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
JNIEnv *env, jclass cls);
+JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
+ JNIEnv *env, jclass cls);
+
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
JNIEnv *env, jclass cls);
@@ -833,6 +836,25 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
SDL_SemPost(Android_ResumeSem);
}
+/* Activity ends */
+JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
+ JNIEnv *env, jclass cls)
+{
+ const char *str;
+
+ if (Android_ActivityMutex) {
+ SDL_DestroyMutex(Android_ActivityMutex);
+ Android_ActivityMutex = NULL;
+ }
+
+ str = SDL_GetError();
+ if (str && str[0]) {
+ __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDLActivity thread ends (error=%s)", str);
+ } else {
+ __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDLActivity thread ends");
+ }
+}
+
/* Pause */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
JNIEnv *env, jclass cls)