Improved default behavior for pause/resume on Android
This commit is contained in:
parent
dfe2a0ac23
commit
5cfc2f618a
2 changed files with 11 additions and 7 deletions
|
@ -143,14 +143,16 @@ See SDL_system.h for more details on these functions.
|
||||||
Pause / Resume behaviour
|
Pause / Resume behaviour
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined, the event loop will
|
If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default),
|
||||||
block itself when the app is paused (ie, when the user returns to the main
|
the event loop will block itself when the app is paused (ie, when the user
|
||||||
Android dashboard). Blocking is better in terms of battery use, and it allows your
|
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||||
app to spring back to life instantaneously after resume (versus polling for
|
use, and it allows your app to spring back to life instantaneously after resume
|
||||||
a resume message).
|
(versus polling for a resume message).
|
||||||
|
|
||||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||||
app can continue to operate as it was.
|
app can continue to operate as it was.
|
||||||
|
|
||||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||||
where the GL context can not be restored. In that case you have to listen for
|
where the GL context can not be restored. In that case you have to listen for
|
||||||
a specific message, (which is not yet implemented!) and restore your textures
|
a specific message, (which is not yet implemented!) and restore your textures
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_ANDROID
|
#if SDL_VIDEO_DRIVER_ANDROID
|
||||||
|
|
||||||
|
/* We're going to do this by default */
|
||||||
|
#define SDL_ANDROID_BLOCK_ON_PAUSE 1
|
||||||
|
|
||||||
#include "SDL_androidevents.h"
|
#include "SDL_androidevents.h"
|
||||||
#include "SDL_events.h"
|
#include "SDL_events.h"
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ Android_PumpEvents(_THIS)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume
|
* Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume
|
||||||
* When the pause semaphoe is signaled, if SDL_ANDROID_BLOCK_ON_PAUSE is defined the event loop will block until the resume signal is emitted.
|
* When the pause semaphore is signaled, if SDL_ANDROID_BLOCK_ON_PAUSE is defined the event loop will block until the resume signal is emitted.
|
||||||
* When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
|
* When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
|
||||||
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
|
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
|
||||||
*/
|
*/
|
||||||
|
@ -77,7 +80,6 @@ Android_PumpEvents(_THIS)
|
||||||
isPaused = 1;
|
isPaused = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue