From 2e837e88b4204c6f97fc9cfe3d997f4da3d5a6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 26 Jul 2026 10:36:21 +0200 Subject: [PATCH] Small simplification --- Core/EmuThread.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Core/EmuThread.cpp b/Core/EmuThread.cpp index 6aaadbd74f..7efe887366 100644 --- a/Core/EmuThread.cpp +++ b/Core/EmuThread.cpp @@ -22,14 +22,12 @@ #include "Core/ConfigValues.h" enum class EmuThreadState { - DISABLED, - START_REQUESTED, RUNNING, QUIT_REQUESTED, STOPPED, }; -static std::atomic g_emuThreadState(EmuThreadState::DISABLED); +static std::atomic g_emuThreadState(EmuThreadState::STOPPED); static std::atomic g_inLoop; class GraphicsContext; @@ -44,10 +42,7 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, Application *applica AndroidJNIThreadContext context; - // There's no real requirement that NativeInit happen on this thread. - // We just call the update/render loop here. - g_emuThreadState = EmuThreadState::RUNNING; - + // This normally calls NativeInitGraphics() if (!application->InitGraphics(graphicsContext)) { _assert_msg_(false, "NativeInitGraphics failed, might as well bail"); // If this fails, which it normally shouldn't, let's bail. @@ -59,6 +54,7 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, Application *applica while (g_emuThreadState != EmuThreadState::QUIT_REQUESTED) { // We're here again, so the game quit. Restart Run() which controls the UI. // This way they can load a new game. + // This normally calls NativeFrame() application->Frame(graphicsContext); if (postFrame) { postFrame(); @@ -72,12 +68,15 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, Application *applica g_emuThreadState = EmuThreadState::STOPPED; + // This normally calls NativeShutdownGraphics() application->ShutdownGraphics(graphicsContext); + INFO_LOG(Log::System, "Leaving separate emu thread"); } std::thread EmuThread_Start(GraphicsContext *graphicsContext, Application *application, std::function postFrame) { - g_emuThreadState = EmuThreadState::START_REQUESTED; + _dbg_assert_(g_emuThreadState == EmuThreadState::STOPPED); + g_emuThreadState = EmuThreadState::RUNNING; std::thread emuThread = std::thread(&EmuThreadFunc, graphicsContext, application, postFrame); return emuThread; }