ANDROID: Implement pause/resume
Don't just kill the whole process when the Activity is stopped. Instead, use its events to pause or resume audio and the running engine (if any). Of course not every engines implements that... but at least an incoming call doesn't kill the game now (lol).
This commit is contained in:
parent
ccfe427eb5
commit
25ef065a41
4 changed files with 52 additions and 18 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue