mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-21 10:48:14 +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:
@@ -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,
|
||||
|
@@ -133,6 +133,7 @@ SDL_bool SDL_IsDeXMode(void);
|
||||
|
||||
void Android_ActivityMutex_Lock(void);
|
||||
void Android_ActivityMutex_Unlock(void);
|
||||
void Android_ActivityMutex_Lock_Running(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
Reference in New Issue
Block a user