Skip to content

Commit

Permalink
Android: same way as in nativePause(), resume events are sent from SD…
Browse files Browse the repository at this point in the history
…L thread
  • Loading branch information
1bsyl committed Dec 21, 2019
1 parent 45a9b5f commit d004cc7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/core/android/SDL_android.c
Expand Up @@ -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)(
Expand Down
10 changes: 10 additions & 0 deletions src/video/android/SDL_androidevents.c
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit d004cc7

Please sign in to comment.