ANDROID: Remove an indirection when pausing

This commit is contained in:
dhewg 2011-03-03 11:35:21 +01:00
parent 1e3c96b3ef
commit a7a7542d1d
5 changed files with 13 additions and 18 deletions

View File

@ -196,6 +196,11 @@ void *OSystem_Android::audioThreadFunc(void *arg) {
while (!system->_audio_thread_exit) {
if (JNI::pause) {
JNI::setAudioStop();
paused = true;
silence_count = 33;
LOGD("audio thread going to sleep");
sem_wait(&JNI::pause_sem);
LOGD("audio thread woke up");

View File

@ -97,8 +97,8 @@ const JNINativeMethod JNI::_natives[] = {
(void *)JNI::pushEvent },
{ "enableZoning", "(Z)V",
(void *)JNI::enableZoning },
{ "pauseEngine", "(Z)V",
(void *)JNI::pauseEngine }
{ "setPause", "(Z)V",
(void *)JNI::setPause }
};
JNI::JNI() {
@ -625,7 +625,7 @@ void JNI::enableZoning(JNIEnv *env, jobject self, jboolean enable) {
_system->enableZoning(enable);
}
void JNI::pauseEngine(JNIEnv *env, jobject self, jboolean value) {
void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
if (!_system)
return;

View File

@ -134,7 +134,7 @@ 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);
static void setPause(JNIEnv *env, jobject self, jboolean value);
};
inline bool JNI::haveSurface() {

View File

@ -44,9 +44,9 @@ 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
// pause the engine and all native threads
final public native void setPause(boolean pause);
final public native void enableZoning(boolean enable);
// Feed an event to ScummVM. Safe to call from other threads.
final public native void pushEvent(Event e);
@ -135,16 +135,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
System.exit(res);
}
public void pause(boolean pause) {
if (audio_track != null && !pause)
audio_track.play();
pauseEngine(pause);
if (audio_track != null && pause)
audio_track.stop();
}
final private void initEGL() throws Exception {
egl = (EGL10)EGLContext.getEGL();
eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

View File

@ -175,7 +175,7 @@ public class ScummVMActivity extends Activity {
super.onResume();
if (scummvm != null)
scummvm.pause(false);
scummvm.setPause(false);
}
@Override
@ -185,7 +185,7 @@ public class ScummVMActivity extends Activity {
super.onPause();
if (scummvm != null)
scummvm.pause(true);
scummvm.setPause(true);
}
@Override