diff options
author | dhewg | 2011-03-02 22:26:15 +0100 |
---|---|---|
committer | dhewg | 2011-03-02 23:18:35 +0100 |
commit | c2d4cce429baa56b5a0962a854ece6163270995f (patch) | |
tree | f9bc843af90c3f8c7e4b978849ba6e7860fc0339 /backends/platform/android/android.cpp | |
parent | 25ef065a4172443eebdd1031c8a387f30f930ec4 (diff) | |
download | scummvm-rg350-c2d4cce429baa56b5a0962a854ece6163270995f.tar.gz scummvm-rg350-c2d4cce429baa56b5a0962a854ece6163270995f.tar.bz2 scummvm-rg350-c2d4cce429baa56b5a0962a854ece6163270995f.zip |
ANDROID: On pause, put all threads in a coma
Since not every engine respects pauseEngine(), or they're in a state
where it simply gets ignored, put all threads in a group coma. Without
this, code still kept looping and wasting cpu cycles, while the user
might want to do use her/his droid for something else.
Diffstat (limited to 'backends/platform/android/android.cpp')
-rw-r--r-- | backends/platform/android/android.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 484f6886ec..d4a2253c30 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -151,6 +151,12 @@ void *OSystem_Android::timerThreadFunc(void *arg) { tv.tv_nsec = 100 * 1000 * 1000; // 100ms while (!system->_timer_thread_exit) { + if (JNI::pause) { + LOGD("timer thread going to sleep"); + sem_wait(&JNI::pause_sem); + LOGD("timer thread woke up"); + } + timer->handler(); nanosleep(&tv, 0); } @@ -192,6 +198,12 @@ void *OSystem_Android::audioThreadFunc(void *arg) { uint silence_count = 33; while (!system->_audio_thread_exit) { + if (JNI::pause) { + LOGD("audio thread going to sleep"); + sem_wait(&JNI::pause_sem); + LOGD("audio thread woke up"); + } + buf = (byte *)env->GetPrimitiveArrayCritical(bufa, 0); assert(buf); @@ -401,6 +413,19 @@ bool OSystem_Android::pollEvent(Common::Event &event) { _screen_changeid = JNI::surface_changeid; JNI::deinitSurface(); } + + if (JNI::pause) { + // release some resources + // TODO + // free textures? they're garbled anyway since no engine + // respects EVENT_SCREEN_CHANGED + LOGD("deinitialiting surface"); + JNI::deinitSurface(); + + LOGD("main thread going to sleep"); + sem_wait(&JNI::pause_sem); + LOGD("main thread woke up"); + } } lockMutex(_event_queue_lock); |