mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-04 07:10:15 +02: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:
@@ -63,9 +63,6 @@ static int Android_DeviceHeight = 0;
|
||||
static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; /* Default SurfaceView format, in case this is queried before being filled */
|
||||
float Android_ScreenDensity = 1.0f;
|
||||
static float Android_ScreenRate = 0.0f;
|
||||
SDL_Semaphore *Android_PauseSem = NULL;
|
||||
SDL_Semaphore *Android_ResumeSem = NULL;
|
||||
SDL_Mutex *Android_ActivityMutex = NULL;
|
||||
static SDL_SystemTheme Android_SystemTheme;
|
||||
|
||||
static int Android_SuspendScreenSaver(SDL_VideoDevice *_this)
|
||||
@@ -83,7 +80,6 @@ static SDL_VideoDevice *Android_CreateDevice(void)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *data;
|
||||
SDL_bool block_on_pause;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
@@ -103,12 +99,6 @@ static SDL_VideoDevice *Android_CreateDevice(void)
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Android_VideoInit;
|
||||
device->VideoQuit = Android_VideoQuit;
|
||||
block_on_pause = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE, SDL_TRUE);
|
||||
if (block_on_pause) {
|
||||
device->PumpEvents = Android_PumpEvents_Blocking;
|
||||
} else {
|
||||
device->PumpEvents = Android_PumpEvents_NonBlocking;
|
||||
}
|
||||
|
||||
device->CreateSDLWindow = Android_CreateWindow;
|
||||
device->SetWindowTitle = Android_SetWindowTitle;
|
||||
@@ -174,7 +164,6 @@ int Android_VideoInit(SDL_VideoDevice *_this)
|
||||
|
||||
videodata->isPaused = SDL_FALSE;
|
||||
videodata->isPausing = SDL_FALSE;
|
||||
videodata->pauseAudio = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO, SDL_TRUE);
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.format = Android_ScreenFormat;
|
||||
|
||||
Reference in New Issue
Block a user