Android: same way as in nativePause(), resume events are sent from SDL thread
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
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 1081b58..6560c89 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -1173,23 +1173,13 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
JNIEnv *env, jclass cls)
{
- SDL_LockMutex(Android_ActivityMutex);
-
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()");
- if (Android_Window) {
- SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
- SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
- SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
- }
-
/* Signal the resume semaphore so the event loop knows to resume and restore the GL Context
* We can't restore the GL Context here because it needs to be done on the SDL main thread
* and this function will be called from the Java thread instead.
*/
SDL_SemPost(Android_ResumeSem);
-
- SDL_UnlockMutex(Android_ActivityMutex);
}
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)(
diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c
index 139eb38..9c62d1c 100644
--- a/src/video/android/SDL_androidevents.c
+++ b/src/video/android/SDL_androidevents.c
@@ -113,6 +113,11 @@ Android_PumpEvents_Blocking(_THIS)
videodata->isPaused = 0;
+ /* Android_ResumeSem was signaled */
+ SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
+ SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
+ SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+
ANDROIDAUDIO_ResumeDevices();
openslES_ResumeDevices();
@@ -179,6 +184,11 @@ Android_PumpEvents_NonBlocking(_THIS)
videodata->isPaused = 0;
+ /* Android_ResumeSem was signaled */
+ SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
+ SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
+ SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+
ANDROIDAUDIO_ResumeDevices();
openslES_ResumeDevices();