app-android: Shave an unnecessary level from the callstack

This commit is contained in:
Henrik Rydgård 2024-02-01 19:21:08 +01:00
parent 533fa14e27
commit da5e29f5dc

View File

@ -115,8 +115,6 @@ enum class EmuThreadState {
static std::thread emuThread;
static std::atomic<int> 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<std::mutex> renderGuard(renderLock);
NativeFrame(graphicsContext);
}
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> renderGuard(renderLock);
NativeFrame(graphicsContext);
}
std::lock_guard<std::mutex> 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<std::mutex> renderGuard(renderLock);
NativeFrame(graphicsContext);
}
ProcessFrameCommands(env);
{
std::lock_guard<std::mutex> guard(frameCommandLock);
ProcessFrameCommands(env);
}
}
INFO_LOG(G3D, "Leaving Vulkan main loop.");
} else {