[Scummvm-git-logs] scummvm master -> 2097e32e3db5cfba230e49e43d503678292473bd

lephilousophe noreply at scummvm.org
Sun Dec 10 16:40:25 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
742bed351a ANDROID: Make application quit even when the application is hidden
2097e32e3d ANDROID: Check for initSurface failures


Commit: 742bed351ab21a1ff46a8977dddf72268173af92
    https://github.com/scummvm/scummvm/commit/742bed351ab21a1ff46a8977dddf72268173af92
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-12-10T17:39:46+01:00

Commit Message:
ANDROID: Make application quit even when the application is hidden

Without this, when the application is in background, it is stuck waiting
for threads to join.
This is handful when, for example, there is an error while the
application got in background.

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/jni-android.cpp
    backends/platform/android/jni-android.h


diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 438ab8c0a95..983149c0ce8 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -816,12 +816,13 @@ Common::MutexInternal *OSystem_Android::createMutex() {
 void OSystem_Android::quit() {
 	ENTER();
 
+	_audio_thread_exit = true;
+	_timer_thread_exit = true;
+
+	JNI::wakeupForQuit();
 	JNI::setReadyForEvents(false);
 
-	_audio_thread_exit = true;
 	pthread_join(_audio_thread, 0);
-
-	_timer_thread_exit = true;
 	pthread_join(_timer_thread, 0);
 }
 
diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 7b8120d7a37..6ea15f70c26 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -222,6 +222,19 @@ void JNI::setReadyForEvents(bool ready) {
 	_ready_for_events = ready;
 }
 
+void JNI::wakeupForQuit() {
+	if (!_system)
+		return;
+
+	if (pause) {
+		pause = false;
+
+		// wake up all threads except the main one as we are run from it
+		for (uint i = 0; i < 2; ++i)
+			sem_post(&pause_sem);
+	}
+}
+
 void JNI::throwByName(JNIEnv *env, const char *name, const char *msg) {
 	jclass cls = env->FindClass(name);
 
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 3f21dbeba7a..27476aed196 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -75,6 +75,7 @@ public:
 	static void detachThread();
 
 	static void setReadyForEvents(bool ready);
+	static void wakeupForQuit();
 
 	static void setWindowCaption(const Common::U32String &caption);
 	static void getDPI(float *values);


Commit: 2097e32e3db5cfba230e49e43d503678292473bd
    https://github.com/scummvm/scummvm/commit/2097e32e3db5cfba230e49e43d503678292473bd
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-12-10T17:39:46+01:00

Commit Message:
ANDROID: Check for initSurface failures

Without a surface we can't do anything, so error out

Changed paths:
    backends/graphics/android/android-graphics.cpp
    backends/graphics3d/android/android-graphics3d.cpp


diff --git a/backends/graphics/android/android-graphics.cpp b/backends/graphics/android/android-graphics.cpp
index 0b36f7a2c14..db96fee9224 100644
--- a/backends/graphics/android/android-graphics.cpp
+++ b/backends/graphics/android/android-graphics.cpp
@@ -91,7 +91,9 @@ void AndroidGraphicsManager::initSurface() {
 	LOGD("initializing 2D surface");
 
 	assert(!JNI::haveSurface());
-	JNI::initSurface();
+	if (!JNI::initSurface()) {
+		error("JNI::initSurface failed");
+	}
 
 	if (JNI::egl_bits_per_pixel == 16) {
 		// We default to RGB565 and RGBA5551 which is closest to what we setup in Java side
@@ -151,7 +153,9 @@ void AndroidGraphicsManager::resizeSurface() {
 
 	// Recreate the EGL surface, context is preserved
 	JNI::deinitSurface();
-	JNI::initSurface();
+	if (!JNI::initSurface()) {
+		error("JNI::initSurface failed");
+	}
 
 	dynamic_cast<OSystem_Android *>(g_system)->getTouchControls().init(
 	    this, JNI::egl_surface_width, JNI::egl_surface_height);
diff --git a/backends/graphics3d/android/android-graphics3d.cpp b/backends/graphics3d/android/android-graphics3d.cpp
index f3aa931aff8..b0aad055456 100644
--- a/backends/graphics3d/android/android-graphics3d.cpp
+++ b/backends/graphics3d/android/android-graphics3d.cpp
@@ -174,7 +174,9 @@ void AndroidGraphics3dManager::initSurface() {
 
 	assert(!JNI::haveSurface());
 
-	JNI::initSurface();
+	if (!JNI::initSurface()) {
+		error("JNI::initSurface failed");
+	}
 
 	_screenChangeID = JNI::surface_changeid;
 
@@ -274,7 +276,9 @@ void AndroidGraphics3dManager::resizeSurface() {
 	}
 
 	JNI::deinitSurface();
-	JNI::initSurface();
+	if (!JNI::initSurface()) {
+		error("JNI::initSurface failed");
+	}
 
 	_screenChangeID = JNI::surface_changeid;
 




More information about the Scummvm-git-logs mailing list