mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-01 10:13:43 +01:00
Apply some minor changes from #8592
This commit is contained in:
1 parent
0be9a520ef
commit
67282cafc4
2 files changed
+54
-32
No files matched your search
+19
-15
@@ -661,6 +661,23 @@ extern "C" jint JNICALL Java_org_ppsspp_ppsspp_NativeApp_getDesiredBackbufferHei
|
||||
return desiredBackbufferSizeY;
|
||||
}
|
||||
|
||||
void ProcessFrameCommands(JNIEnv *env) {
|
||||
lock_guard guard(frameCommandLock);
|
||||
while (!frameCommands.empty()) {
|
||||
FrameCommand frameCmd;
|
||||
frameCmd = frameCommands.front();
|
||||
frameCommands.pop();
|
||||
|
||||
WLOG("frameCommand! '%s' '%s'", frameCmd.command.c_str(), frameCmd.params.c_str());
|
||||
|
||||
jstring cmd = env->NewStringUTF(frameCmd.command.c_str());
|
||||
jstring param = env->NewStringUTF(frameCmd.params.c_str());
|
||||
env->CallVoidMethod(nativeActivity, postCommand, cmd, param);
|
||||
env->DeleteLocalRef(cmd);
|
||||
env->DeleteLocalRef(param);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(JNIEnv *env, jobject obj, jobject _surf) {
|
||||
ANativeWindow *wnd = ANativeWindow_fromSurface(env, _surf);
|
||||
|
||||
@@ -716,20 +733,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
|
||||
|
||||
graphicsContext->SwapBuffers();
|
||||
|
||||
lock_guard guard(frameCommandLock);
|
||||
while (!frameCommands.empty()) {
|
||||
FrameCommand frameCmd;
|
||||
frameCmd = frameCommands.front();
|
||||
frameCommands.pop();
|
||||
|
||||
WLOG("frameCommand! '%s' '%s'", frameCmd.command.c_str(), frameCmd.params.c_str());
|
||||
|
||||
jstring cmd = env->NewStringUTF(frameCmd.command.c_str());
|
||||
jstring param = env->NewStringUTF(frameCmd.params.c_str());
|
||||
env->CallVoidMethod(nativeActivity, postCommand, cmd, param);
|
||||
env->DeleteLocalRef(cmd);
|
||||
env->DeleteLocalRef(param);
|
||||
}
|
||||
ProcessFrameCommands(env);
|
||||
}
|
||||
|
||||
// Restore lost device objects. TODO: This feels like the wrong place for this.
|
||||
@@ -742,6 +746,6 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
|
||||
graphicsContext->Shutdown();
|
||||
|
||||
renderLoopRunning = false;
|
||||
WLOG("Render loop exited;");
|
||||
WLOG("Render loop function exited.");
|
||||
return true;
|
||||
}
|
||||
@@ -417,26 +417,40 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
protected void ensureRenderLoop() {
|
||||
if ((mRenderLoopThread == null || !mRenderLoopThread.isAlive()) && mSurface != null) {
|
||||
if (mSurface == null) {
|
||||
Log.w(TAG, "ensureRenderLoop - not starting thread, needs surface");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((mRenderLoopThread == null || !mRenderLoopThread.isAlive())) {
|
||||
Log.w(TAG, "ensureRenderLoop: Starting thread");
|
||||
mRenderLoopThread = new Thread(mEmulationRunner);
|
||||
mRenderLoopThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void joinRenderLoopThread() {
|
||||
if (mRenderLoopThread != null && mRenderLoopThread.isAlive()) {
|
||||
// This will wait until the thread has exited.
|
||||
Log.i(TAG, "exitEGLRenderLoop");
|
||||
exitEGLRenderLoop();
|
||||
try {
|
||||
Log.i(TAG, "joining render loop thread...");
|
||||
mRenderLoopThread.join();
|
||||
Log.w(TAG, "Joined render loop thread.");
|
||||
mRenderLoopThread = null;
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
mSurface = null;
|
||||
Log.w(TAG, "Surface destroyed.");
|
||||
if (mRenderLoopThread != null && mRenderLoopThread.isAlive()) {
|
||||
// This will wait until the thread has exited.
|
||||
exitEGLRenderLoop();
|
||||
try {
|
||||
mRenderLoopThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
joinRenderLoopThread();
|
||||
}
|
||||
|
||||
|
||||
@@ -454,7 +468,6 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
exitEGLRenderLoop();
|
||||
super.onStop();
|
||||
Log.i(TAG, "onStop - do nothing special");
|
||||
}
|
||||
@@ -478,11 +491,15 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Log.i(TAG, "onPause");
|
||||
loseAudioFocus(this.audioManager, this.audioFocusChangeListener);
|
||||
NativeApp.pause();
|
||||
mSurfaceView.onPause();
|
||||
super.onPause();
|
||||
Log.i(TAG, "onPause");
|
||||
loseAudioFocus(this.audioManager, this.audioFocusChangeListener);
|
||||
Log.i(TAG, "Pausing surface view");
|
||||
NativeApp.pause();
|
||||
mSurfaceView.onPause();
|
||||
Log.i(TAG, "Joining render thread");
|
||||
joinRenderLoopThread();
|
||||
Log.i(TAG, "onPause completed");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -948,6 +965,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
}
|
||||
return true;
|
||||
} else if (command.equals("finish")) {
|
||||
Log.i(TAG, "Setting shuttingDown = true and calling Finish");
|
||||
shuttingDown = true;
|
||||
finish();
|
||||
} else if (command.equals("rotate")) {
|
||||
|
||||
Reference in new issue
Block a user