Android: create Pause/ResumeSem semaphore at higher level than CreateWindow()

- If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background.

- If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids.

SDLActivity.java: the first resume() starts the SDLThread, don't call
nativeResume() as it would post ResumeSem. And the first pause would
automatically be resumed.
This commit is contained in:
Sylvain Becker
2019-01-14 23:33:48 +01:00
parent 1b24b2eca5
commit dc263450ff
3 changed files with 39 additions and 20 deletions

View File

@@ -49,9 +49,6 @@ Android_CreateWindow(_THIS, SDL_Window * window)
goto endfunction;
}
Android_PauseSem = SDL_CreateSemaphore(0);
Android_ResumeSem = SDL_CreateSemaphore(0);
/* Set orientation */
Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS));
@@ -171,10 +168,6 @@ Android_DestroyWindow(_THIS, SDL_Window *window)
if (window == Android_Window) {
Android_Window = NULL;
if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem);
if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem);
Android_PauseSem = NULL;
Android_ResumeSem = NULL;
if (window->driverdata) {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;