mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-06 07:20:48 +00:00
Android: concurrency issues, make sure Activity is in running State when calling
functions like SDL_CreateWindow, SDL_CreateRenderer, Android_GLES_CreateContext Bugs 4694, 4681, 4142
This commit is contained in:
parent
cfed0b7738
commit
22a2decf64
5 changed files with 45 additions and 2 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "SDL_hints.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_timer.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
|
@ -720,6 +721,25 @@ void Android_ActivityMutex_Unlock() {
|
|||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Lock the Mutex when the Activity is in its 'Running' state */
|
||||
void Android_ActivityMutex_Lock_Running() {
|
||||
int pauseSignaled = 0;
|
||||
int resumeSignaled = 0;
|
||||
|
||||
retry:
|
||||
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
|
||||
pauseSignaled = SDL_SemValue(Android_PauseSem);
|
||||
resumeSignaled = SDL_SemValue(Android_ResumeSem);
|
||||
|
||||
if (pauseSignaled > resumeSignaled) {
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
SDL_Delay(50);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set screen resolution */
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue