Android: allow multiple calls to nativeResume()
authorSylvain Becker <sylvain.becker@gmail.com>
Sun, 06 Jan 2019 17:35:42 +0100
changeset 12508662cdc7f1dea
parent 12507 6a5107360fbc
child 12509 8faf3241a2b7
Android: allow multiple calls to nativeResume()

Doesn't seem to happen manually, but symetrical to the pause handling.

Can be tested by adding:

mNextNativeState = SDLActivity.NativeState.PAUSED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.RESUMED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.PAUSED;
handleNativeState();
mNextNativeState = SDLActivity.NativeState.RESUMED;
handleNativeState();

Before, it ends in 'paused' state.
Now, it ends in 'resumed' state.
src/core/android/SDL_android.c
     1.1 --- a/src/core/android/SDL_android.c	Sat Jan 05 22:49:50 2019 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Sun Jan 06 17:35:42 2019 +0100
     1.3 @@ -802,7 +802,7 @@
     1.4      SDL_SendAppEvent(SDL_APP_TERMINATING);
     1.5      /* Resume the event loop so that the app can catch SDL_QUIT which
     1.6       * should now be the top event in the event queue. */
     1.7 -    if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem);
     1.8 +    SDL_SemPost(Android_ResumeSem);
     1.9  }
    1.10  
    1.11  /* Pause */
    1.12 @@ -853,7 +853,7 @@
    1.13           * We can't restore the GL Context here because it needs to be done on the SDL main thread
    1.14           * and this function will be called from the Java thread instead.
    1.15           */
    1.16 -        if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem);
    1.17 +        SDL_SemPost(Android_ResumeSem);
    1.18      }
    1.19  
    1.20      SDL_UnlockMutex(Android_ActivityMutex);