diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index a568076fbe..76d41e8d5e 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -115,8 +115,6 @@ enum class EmuThreadState { static std::thread emuThread; static std::atomic emuThreadState((int)EmuThreadState::DISABLED); -void UpdateRunLoopAndroid(JNIEnv *env); - AndroidAudioState *g_audioState; struct FrameCommand { @@ -202,6 +200,8 @@ int utimensat(int fd, const char *path, const struct timespec times[2]) { } #endif +static void ProcessFrameCommands(JNIEnv *env); + void AndroidLogger::Log(const LogMessage &message) { int mode; switch (message.level) { @@ -337,8 +337,22 @@ static void EmuThreadFunc() { // We just call the update/render loop here. emuThreadState = (int)EmuThreadState::RUNNING; while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) { - UpdateRunLoopAndroid(env); + { + std::lock_guard renderGuard(renderLock); + NativeFrame(graphicsContext); + } + + std::lock_guard guard(frameCommandLock); + if (!nativeActivity) { + ERROR_LOG(SYSTEM, "No activity, clearing commands"); + while (!frameCommands.empty()) + frameCommands.pop(); + return; + } + // Still under lock here. + ProcessFrameCommands(env); } + INFO_LOG(SYSTEM, "QUIT_REQUESTED found, left EmuThreadFunc loop. Setting state to STOPPED."); emuThreadState = (int)EmuThreadState::STOPPED; @@ -371,8 +385,6 @@ static void EmuThreadJoin() { INFO_LOG(SYSTEM, "EmuThreadJoin - joined"); } -static void ProcessFrameCommands(JNIEnv *env); - static void PushCommand(std::string cmd, std::string param) { std::lock_guard guard(frameCommandLock); frameCommands.push(FrameCommand(cmd, param)); @@ -1162,23 +1174,6 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEn } } -void UpdateRunLoopAndroid(JNIEnv *env) { - { - std::lock_guard renderGuard(renderLock); - NativeFrame(graphicsContext); - } - - std::lock_guard guard(frameCommandLock); - if (!nativeActivity) { - ERROR_LOG(SYSTEM, "No activity, clearing commands"); - while (!frameCommands.empty()) - frameCommands.pop(); - return; - } - // Still under lock here. - ProcessFrameCommands(env); -} - extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) { // This doesn't get called on the Vulkan path. _assert_(useCPUThread); @@ -1641,7 +1636,10 @@ static void VulkanEmuThread(ANativeWindow *wnd) { std::lock_guard renderGuard(renderLock); NativeFrame(graphicsContext); } - ProcessFrameCommands(env); + { + std::lock_guard guard(frameCommandLock); + ProcessFrameCommands(env); + } } INFO_LOG(G3D, "Leaving Vulkan main loop."); } else {