mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-28 23:49:12 +00:00
Android life cycle behavior more closely matches iOS
This change also decouples the pause/resume handling from the video subsystem on Android, so applications that don't use SDL for video can get application life cycle events. The semantics for the life cycle events are that they need to be handled in an event watch callback, and once they've been delivered, the application will block until it's been resumed. SDL_HINT_ANDROID_BLOCK_ON_PAUSE can be used to control that behavior, and if that's set to "0", then the application will continue to run in the background at low CPU usage until being resumed or stopped. SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO has been removed, and the audio will be paused when the application is paused. Fixes https://github.com/libsdl-org/SDL/issues/3193
This commit is contained in:
parent
fff783de6c
commit
ca4bd4b63c
15 changed files with 183 additions and 207 deletions
|
@ -403,6 +403,10 @@ static jobject javaAssetManagerRef = 0;
|
|||
/* Re-create activity hint */
|
||||
static SDL_AtomicInt bAllowRecreateActivity;
|
||||
|
||||
static SDL_Mutex *Android_ActivityMutex = NULL;
|
||||
SDL_Semaphore *Android_PauseSem = NULL;
|
||||
SDL_Semaphore *Android_ResumeSem = NULL;
|
||||
|
||||
/*******************************************************************************
|
||||
Functions called by JNI
|
||||
*******************************************************************************/
|
||||
|
@ -903,18 +907,18 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
|
|||
}
|
||||
|
||||
/* Lock / Unlock Mutex */
|
||||
void Android_ActivityMutex_Lock(void)
|
||||
void Android_LockActivityMutex(void)
|
||||
{
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
void Android_ActivityMutex_Unlock(void)
|
||||
void Android_UnlockActivityMutex(void)
|
||||
{
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
||||
/* Lock the Mutex when the Activity is in its 'Running' state */
|
||||
void Android_ActivityMutex_Lock_Running(void)
|
||||
void Android_LockActivityMutexOnceRunning(void)
|
||||
{
|
||||
int pauseSignaled = 0;
|
||||
int resumeSignaled = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue