mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 03:10:22 +00:00
ANDROID: Avoid calling native code from UI thread
This can lead to race conditions. When synchronizing virtual keyboard state, just set a variable in UI thread. The variable will be read in worker thread during event polling, this will ensure that graphics code is configured at a proper time.
This commit is contained in:
parent
5964c36ab4
commit
a58bac8ccb
@ -951,11 +951,6 @@ int OSystem_Android::getGraphicsMode() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OSystem_Android::syncVirtkeyboardState(bool virtkeybd_on) {
|
||||
_virtkeybd_on = virtkeybd_on;
|
||||
dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->syncVirtkeyboardState(virtkeybd_on);
|
||||
}
|
||||
|
||||
#if defined(USE_OPENGL) && defined(USE_GLAD)
|
||||
void *OSystem_Android::getOpenGLProcAddress(const char *name) const {
|
||||
// eglGetProcAddress exists since Android 2.3 (API Level 9)
|
||||
|
@ -188,8 +188,6 @@ public:
|
||||
void applyTouchSettings(bool _3dMode, bool overlayShown);
|
||||
void setupTouchMode(int oldValue, int newValue);
|
||||
|
||||
void syncVirtkeyboardState(bool virtkeybd_on);
|
||||
|
||||
void applyOrientationSettings();
|
||||
|
||||
bool pollEvent(Common::Event &event) override;
|
||||
|
@ -1439,6 +1439,11 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (_virtkeybd_on != JNI::virt_keyboard_state) {
|
||||
_virtkeybd_on = JNI::virt_keyboard_state;
|
||||
dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->syncVirtkeyboardState(_virtkeybd_on);
|
||||
}
|
||||
|
||||
if (JNI::pause) {
|
||||
LOGD("main thread going to sleep");
|
||||
sem_wait(&JNI::pause_sem);
|
||||
|
@ -79,6 +79,7 @@ int JNI::egl_surface_width = 0;
|
||||
int JNI::egl_surface_height = 0;
|
||||
int JNI::egl_bits_per_pixel = 0;
|
||||
bool JNI::_ready_for_events = 0;
|
||||
bool JNI::virt_keyboard_state = false;
|
||||
|
||||
jmethodID JNI::_MID_getDPI = 0;
|
||||
jmethodID JNI::_MID_displayMessageOnOSD = 0;
|
||||
@ -969,7 +970,7 @@ void JNI::syncVirtkeyboardState(JNIEnv *env, jobject self, jboolean newState) {
|
||||
if (!_system)
|
||||
return;
|
||||
|
||||
_system->syncVirtkeyboardState(newState);
|
||||
JNI::virt_keyboard_state = newState;
|
||||
}
|
||||
|
||||
void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
static int egl_surface_height;
|
||||
static int egl_bits_per_pixel;
|
||||
|
||||
static bool virt_keyboard_state;
|
||||
|
||||
static jint onLoad(JavaVM *vm);
|
||||
|
||||
static inline JNIEnv *getEnv() {
|
||||
|
Loading…
Reference in New Issue
Block a user