Improved default behavior for pause/resume on Android
authorSam Lantinga <slouken@libsdl.org>
Wed, 07 Nov 2012 20:17:27 -0800
changeset 66642deb17aefbaf
parent 6663 2cbffb5aa19d
child 6665 c0ea8c57034c
Improved default behavior for pause/resume on Android
README.android
src/video/android/SDL_androidevents.c
     1.1 --- a/README.android	Wed Nov 07 20:17:07 2012 -0800
     1.2 +++ b/README.android	Wed Nov 07 20:17:27 2012 -0800
     1.3 @@ -143,14 +143,16 @@
     1.4   Pause / Resume behaviour
     1.5  ================================================================================
     1.6  
     1.7 -If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined, the event loop will
     1.8 -block itself when the app is paused (ie, when the user returns to the main
     1.9 -Android dashboard). Blocking is better in terms of battery use, and it allows your
    1.10 -app to spring back to life instantaneously after resume (versus polling for
    1.11 -a resume message).
    1.12 +If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default),
    1.13 +the event loop will block itself when the app is paused (ie, when the user
    1.14 +returns to the main Android dashboard). Blocking is better in terms of battery
    1.15 +use, and it allows your app to spring back to life instantaneously after resume
    1.16 +(versus polling for a resume message).
    1.17 +
    1.18  Upon resume, SDL will attempt to restore the GL context automatically.
    1.19  In modern devices (Android 3.0 and up) this will most likely succeed and your
    1.20  app can continue to operate as it was.
    1.21 +
    1.22  However, there's a chance (on older hardware, or on systems under heavy load),
    1.23  where the GL context can not be restored. In that case you have to listen for
    1.24  a specific message, (which is not yet implemented!) and restore your textures
     2.1 --- a/src/video/android/SDL_androidevents.c	Wed Nov 07 20:17:07 2012 -0800
     2.2 +++ b/src/video/android/SDL_androidevents.c	Wed Nov 07 20:17:27 2012 -0800
     2.3 @@ -22,6 +22,9 @@
     2.4  
     2.5  #if SDL_VIDEO_DRIVER_ANDROID
     2.6  
     2.7 +/* We're going to do this by default */
     2.8 +#define SDL_ANDROID_BLOCK_ON_PAUSE  1
     2.9 +
    2.10  #include "SDL_androidevents.h"
    2.11  #include "SDL_events.h"
    2.12  
    2.13 @@ -36,7 +39,7 @@
    2.14  
    2.15      /*
    2.16       * Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume
    2.17 -     * 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.
    2.18 +     * 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.
    2.19       * When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
    2.20       * SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
    2.21       */
    2.22 @@ -77,7 +80,6 @@
    2.23              isPaused = 1;
    2.24          }
    2.25  #endif
    2.26 -
    2.27      }
    2.28  }
    2.29