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:
Sam Lantinga
2024-07-23 20:55:24 -07:00
parent fff783de6c
commit ca4bd4b63c
15 changed files with 183 additions and 207 deletions

View File

@@ -52,6 +52,7 @@
#include "thread/SDL_thread_c.h"
#include "video/SDL_pixels_c.h"
#include "video/SDL_video_c.h"
#include "video/android/SDL_androidevents.h"
#include "filesystem/SDL_filesystem_c.h"
#define SDL_INIT_EVERYTHING ~0U
@@ -225,6 +226,10 @@ int SDL_InitSubSystem(Uint32 flags)
SDL_InitMainThread();
#ifdef SDL_PLATFORM_ANDROID
Android_InitEvents();
#endif
#ifdef SDL_USE_LIBDBUS
SDL_DBus_Init();
#endif
@@ -571,6 +576,10 @@ void SDL_Quit(void)
SDL_DBus_Quit();
#endif
#ifdef SDL_PLATFORM_ANDROID
Android_QuitEvents();
#endif
SDL_SetObjectsInvalid();
SDL_ClearHints();
SDL_AssertionsQuit();