From 1da7acbabaec77ce8477e813ce92979892ea9ff3 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sat, 6 Jun 2015 21:18:27 -0700 Subject: [PATCH] Properly hook up Android shutdown paths --- Android/jni/jnihooks.c | 8 ++++++++ src/video/glvideo.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Android/jni/jnihooks.c b/Android/jni/jnihooks.c index a49f400d..eea9a582 100644 --- a/Android/jni/jnihooks.c +++ b/Android/jni/jnihooks.c @@ -111,6 +111,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsInitialized(JNIEnv LOG("native graphicsInitialized width:%d height:%d", width, height); static bool graphicsPreviouslyInitialized = false; if (graphicsPreviouslyInitialized) { + LOG("shutting down previous context"); video_backend->shutdown(); } graphicsPreviouslyInitialized = true; @@ -144,6 +145,10 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnPause(JNIEnv *env, jobjec } void Java_org_deadc0de_apple2ix_Apple2Activity_nativeRender(JNIEnv *env, jobject obj) { + if (UNLIKELY(emulator_shutting_down)) { + return; + } + if (!nativePaused) { c_keys_handle_input(-1, 0, 0); } @@ -242,6 +247,9 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnKeyUp(JNIEnv *env, jobjec jboolean Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnTouch(JNIEnv *env, jobject obj, jint action, jint pointerCount, jint pointerIndex, jfloatArray xCoords, jfloatArray yCoords) { //LOG("nativeOnTouch : %d/%d/%d :", action, pointerCount, pointerIndex); + if (UNLIKELY(emulator_shutting_down)) { + return true; + } if (nativePaused) { LOG("UNPAUSING NATIVE CPU THREAD"); diff --git a/src/video/glvideo.c b/src/video/glvideo.c index c2d46702..42177f3f 100644 --- a/src/video/glvideo.c +++ b/src/video/glvideo.c @@ -318,7 +318,7 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc if (version) { sprintf(sourceString, "#version %d\n%s", version, vertexSource->string); } else { - RELEASE_LOG("YAY, you have an awesome OpenGL vendor for this device ... no GLSL version specified ... so NOT adding a #version directive to shader sources =P"); + RELEASE_LOG("No GLSL version specified ... so NOT adding a #version directive to shader sources =P"); sprintf(sourceString, "%s", vertexSource->string); } @@ -631,6 +631,7 @@ static void gldriver_shutdown(void) { #else # if MOBILE_DEVICE // it could be a temporary backgrounding do nothing here ... + _gldriver_shutdown(); # else emulator_shutting_down = true; # endif