@@ -115,8 +115,6 @@ enum class EmuThreadState {
115
115
static std::thread emuThread;
116
116
static std::atomic<int > emuThreadState ((int )EmuThreadState::DISABLED);
117
117
118
- void UpdateRunLoopAndroid (JNIEnv *env);
119
-
120
118
AndroidAudioState *g_audioState;
121
119
122
120
struct FrameCommand {
@@ -202,6 +200,8 @@ int utimensat(int fd, const char *path, const struct timespec times[2]) {
202
200
}
203
201
#endif
204
202
203
+ static void ProcessFrameCommands (JNIEnv *env);
204
+
205
205
void AndroidLogger::Log (const LogMessage &message) {
206
206
int mode;
207
207
switch (message.level ) {
@@ -337,8 +337,22 @@ static void EmuThreadFunc() {
337
337
// We just call the update/render loop here.
338
338
emuThreadState = (int )EmuThreadState::RUNNING;
339
339
while (emuThreadState != (int )EmuThreadState::QUIT_REQUESTED) {
340
- UpdateRunLoopAndroid (env);
340
+ {
341
+ std::lock_guard<std::mutex> renderGuard (renderLock);
342
+ NativeFrame (graphicsContext);
343
+ }
344
+
345
+ std::lock_guard<std::mutex> guard (frameCommandLock);
346
+ if (!nativeActivity) {
347
+ ERROR_LOG (SYSTEM, " No activity, clearing commands" );
348
+ while (!frameCommands.empty ())
349
+ frameCommands.pop ();
350
+ return ;
351
+ }
352
+ // Still under lock here.
353
+ ProcessFrameCommands (env);
341
354
}
355
+
342
356
INFO_LOG (SYSTEM, " QUIT_REQUESTED found, left EmuThreadFunc loop. Setting state to STOPPED." );
343
357
emuThreadState = (int )EmuThreadState::STOPPED;
344
358
@@ -371,8 +385,6 @@ static void EmuThreadJoin() {
371
385
INFO_LOG (SYSTEM, " EmuThreadJoin - joined" );
372
386
}
373
387
374
- static void ProcessFrameCommands (JNIEnv *env);
375
-
376
388
static void PushCommand (std::string cmd, std::string param) {
377
389
std::lock_guard<std::mutex> guard (frameCommandLock);
378
390
frameCommands.push (FrameCommand (cmd, param));
@@ -1162,23 +1174,6 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEn
1162
1174
}
1163
1175
}
1164
1176
1165
- void UpdateRunLoopAndroid (JNIEnv *env) {
1166
- {
1167
- std::lock_guard<std::mutex> renderGuard (renderLock);
1168
- NativeFrame (graphicsContext);
1169
- }
1170
-
1171
- std::lock_guard<std::mutex> guard (frameCommandLock);
1172
- if (!nativeActivity) {
1173
- ERROR_LOG (SYSTEM, " No activity, clearing commands" );
1174
- while (!frameCommands.empty ())
1175
- frameCommands.pop ();
1176
- return ;
1177
- }
1178
- // Still under lock here.
1179
- ProcessFrameCommands (env);
1180
- }
1181
-
1182
1177
extern " C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender (JNIEnv *env, jobject obj) {
1183
1178
// This doesn't get called on the Vulkan path.
1184
1179
_assert_ (useCPUThread);
@@ -1641,7 +1636,10 @@ static void VulkanEmuThread(ANativeWindow *wnd) {
1641
1636
std::lock_guard<std::mutex> renderGuard (renderLock);
1642
1637
NativeFrame (graphicsContext);
1643
1638
}
1644
- ProcessFrameCommands (env);
1639
+ {
1640
+ std::lock_guard<std::mutex> guard (frameCommandLock);
1641
+ ProcessFrameCommands (env);
1642
+ }
1645
1643
}
1646
1644
INFO_LOG (G3D, " Leaving Vulkan main loop." );
1647
1645
} else {
0 commit comments