Refactor pause/resume functions to be strictly CPU thread pause/resume

This commit is contained in:
Aaron Culliney 2015-10-31 14:01:47 -07:00
parent e52f753bf3
commit acdc8da64f
3 changed files with 15 additions and 17 deletions

View File

@ -98,9 +98,9 @@ public class Apple2Activity extends Activity {
private native void nativeOnKeyUp(int keyCode, int metaState);
private native void nativeOnResume(boolean isSystemResume);
private native void nativeEmulationResume();
public native void nativeOnPause(boolean isSystemPause);
public native void nativeEmulationPause();
public native void nativeOnQuit();
@ -196,7 +196,6 @@ public class Apple2Activity extends Activity {
Log.d(TAG, "onResume()");
mView.onResume();
nativeOnResume(/*isSystemResume:*/true);
}
@Override
@ -218,7 +217,7 @@ public class Apple2Activity extends Activity {
// Dismiss these popups to avoid android.view.WindowLeaked issues
synchronized (this) {
dismissAllMenus();
nativeOnPause(true);
nativeEmulationPause();
}
mPausing.set(false);
@ -356,6 +355,8 @@ public class Apple2Activity extends Activity {
}
void graphicsInitialized(int w, int h) {
Log.v(TAG, "graphicsInitialized(" + w + ", " + h + ")");
if (mMainMenu == null) {
mMainMenu = new Apple2MainMenu(this, mView);
}
@ -370,7 +371,6 @@ public class Apple2Activity extends Activity {
mWidth = w;
mHeight = h;
// tell native about this...
nativeGraphicsInitialized(w, h);
showSplashScreen();
@ -478,7 +478,7 @@ public class Apple2Activity extends Activity {
public synchronized void pushApple2View(Apple2MenuView apple2MenuView) {
mMenuStack.add(apple2MenuView);
View menuView = apple2MenuView.getView();
nativeOnPause(false);
nativeEmulationPause();
addContentView(menuView, new FrameLayout.LayoutParams(getWidth(), getHeight()));
}
@ -560,13 +560,13 @@ public class Apple2Activity extends Activity {
dismissAllMenus();
}
if (mMenuStack.size() == 0 && !mPausing.get()) {
nativeOnResume(/*isSystemResume:*/false);
nativeEmulationResume();
}
}
void _mainMenuDismissed() {
if (mMenuStack.size() == 0 && !mPausing.get()) {
nativeOnResume(/*isSystemResume:*/false);
nativeEmulationResume();
}
}
@ -583,7 +583,7 @@ public class Apple2Activity extends Activity {
}
public void maybeQuitApp() {
nativeOnPause(false);
nativeEmulationPause();
AlertDialog quitDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.quit_really).setMessage(R.string.quit_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -606,7 +606,7 @@ public class Apple2Activity extends Activity {
}
public void maybeReboot() {
nativeOnPause(false);
nativeEmulationPause();
AlertDialog rebootDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.reboot_really).setMessage(R.string.reboot_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View File

@ -203,7 +203,7 @@ public class Apple2MainMenu {
return;
}
mActivity.nativeOnPause(false);
mActivity.nativeEmulationPause();
mMainMenuPopup.showAtLocation(mParentView, Gravity.CENTER, 0, 0);
}

View File

@ -186,21 +186,19 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeGraphicsInitialized(JNIEnv
video_backend->init((void *)0);
}
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnResume(JNIEnv *env, jobject obj, jboolean isSystemResume) {
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env, jobject obj) {
if (!cpu_isPaused()) {
return;
}
LOG("...");
if (!isSystemResume) {
#if TESTING
// test driver thread is managing CPU
// test driver thread is managing CPU
#else
cpu_resume();
cpu_resume();
#endif
}
}
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnPause(JNIEnv *env, jobject obj, jboolean isSystemPause) {
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationPause(JNIEnv *env, jobject obj) {
if (appState != APP_RUNNING) {
return;
}