Android: Block for window changes/surface destruction

This commit is contained in:
Connor McLaughlin 2021-01-27 01:01:07 +10:00
parent 368820d6e9
commit 0b4363679c
2 changed files with 5 additions and 1 deletions

View file

@ -1001,10 +1001,12 @@ DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_surfaceChanged, jobject obj, j
if (surface && !native_surface) if (surface && !native_surface)
Log_ErrorPrint("ANativeWindow_fromSurface() returned null"); Log_ErrorPrint("ANativeWindow_fromSurface() returned null");
// We should wait for the emu to finish if the surface is being destroyed or changed.
AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj); AndroidHostInterface* hi = AndroidHelpers::GetNativeClass(env, obj);
const bool block = (!native_surface || native_surface != hi->GetSurface());
hi->RunOnEmulationThread( hi->RunOnEmulationThread(
[hi, native_surface, format, width, height]() { hi->SurfaceChanged(native_surface, format, width, height); }, [hi, native_surface, format, width, height]() { hi->SurfaceChanged(native_surface, format, width, height); },
false); block);
} }
DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_setControllerType, jobject obj, jint index, jstring controller_type) DEFINE_JNI_ARGS_METHOD(void, AndroidHostInterface_setControllerType, jobject obj, jint index, jstring controller_type)

View file

@ -24,6 +24,8 @@ public:
AndroidHostInterface(jobject java_object, jobject context_object, std::string user_directory); AndroidHostInterface(jobject java_object, jobject context_object, std::string user_directory);
~AndroidHostInterface() override; ~AndroidHostInterface() override;
ALWAYS_INLINE ANativeWindow* GetSurface() const { return m_surface; }
bool Initialize() override; bool Initialize() override;
void Shutdown() override; void Shutdown() override;