aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/android/jni.cpp13
-rw-r--r--backends/platform/android/jni.h2
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVM.java13
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java42
4 files changed, 52 insertions, 18 deletions
diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 7fe23d0d19..1e28b065b4 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -27,6 +27,7 @@
#include "base/main.h"
#include "common/config-manager.h"
+#include "engines/engine.h"
#include "backends/platform/android/android.h"
#include "backends/platform/android/asset-archive.h"
@@ -93,6 +94,8 @@ const JNINativeMethod JNI::_natives[] = {
(void *)JNI::pushEvent },
{ "enableZoning", "(Z)V",
(void *)JNI::enableZoning },
+ { "pauseEngine", "(Z)V",
+ (void *)JNI::pauseEngine }
};
JNI::JNI() {
@@ -613,5 +616,15 @@ void JNI::enableZoning(JNIEnv *env, jobject self, jboolean enable) {
_system->enableZoning(enable);
}
+void JNI::pauseEngine(JNIEnv *env, jobject self, jboolean pause) {
+ if (!_system || !g_engine)
+ return;
+
+ if ((pause && !g_engine->isPaused()) || (!pause && g_engine->isPaused())) {
+ LOGD("pauseEngine: %d", pause);
+ g_engine->pauseEngine(pause);
+ }
+}
+
#endif
diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h
index d2bc89e3d1..7eb10791aa 100644
--- a/backends/platform/android/jni.h
+++ b/backends/platform/android/jni.h
@@ -129,6 +129,8 @@ private:
static void pushEvent(JNIEnv *env, jobject self, jobject java_event);
static void enableZoning(JNIEnv *env, jobject self, jboolean enable);
+
+ static void pauseEngine(JNIEnv *env, jobject self, jboolean pause);
};
inline bool JNI::haveSurface() {
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
index 75407c66cc..ffb0109e6c 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
@@ -44,6 +44,7 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
final private native void destroy();
final private native void setSurface(int width, int height);
final private native int main(String[] args);
+ final private native void pauseEngine(boolean pause);
// Set scummvm config options
final public native void enableZoning(boolean enable);
@@ -134,12 +135,14 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
System.exit(res);
}
- public void pause() {
- // TODO
- }
+ public void pause(boolean pause) {
+ if (audio_track != null && !pause)
+ audio_track.play();
+
+ pauseEngine(pause);
- public void resume() {
- // TODO
+ if (audio_track != null && pause)
+ audio_track.stop();
}
final private void initEGL() throws Exception {
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
index 92247dea96..22ccaf0b62 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
@@ -161,30 +161,46 @@ public class ScummVMActivity extends Activity {
scummvm_thread.start();
}
- private boolean was_paused = false;
-
@Override
- public void onPause() {
- if (scummvm != null) {
- was_paused = true;
- scummvm.pause();
- }
+ public void onStart() {
+ Log.d(ScummVM.LOG_TAG, "onStart");
- super.onPause();
+ super.onStart();
}
@Override
public void onResume() {
+ Log.d(ScummVM.LOG_TAG, "onResume");
+
super.onResume();
- if (scummvm != null && was_paused)
- scummvm.resume();
+ if (scummvm != null)
+ scummvm.pause(false);
+ }
+
+ @Override
+ public void onPause() {
+ Log.d(ScummVM.LOG_TAG, "onPause");
+
+ super.onPause();
- was_paused = false;
+ if (scummvm != null)
+ scummvm.pause(true);
}
@Override
public void onStop() {
+ Log.d(ScummVM.LOG_TAG, "onStop");
+
+ super.onStop();
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.d(ScummVM.LOG_TAG, "onDestroy");
+
+ super.onDestroy();
+
if (scummvm != null) {
scummvm.pushEvent(new Event(Event.EVENT_QUIT));
@@ -194,9 +210,9 @@ public class ScummVMActivity extends Activity {
} catch (InterruptedException e) {
Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e);
}
- }
- super.onStop();
+ scummvm = null;
+ }
}
static final int MSG_MENU_LONG_PRESS = 1;