Fixed hanging after onDestroy() on Android
This commit is contained in:
parent
9826f73230
commit
e9a7014e56
1 changed files with 25 additions and 10 deletions
|
@ -97,6 +97,24 @@ void Android_InitEvents(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Android_PauseAudio(void)
|
||||||
|
{
|
||||||
|
ANDROIDAUDIO_PauseDevices();
|
||||||
|
OPENSLES_PauseDevices();
|
||||||
|
AAUDIO_PauseDevices();
|
||||||
|
Android_PausedAudio = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Android_ResumeAudio(void)
|
||||||
|
{
|
||||||
|
if (Android_PausedAudio) {
|
||||||
|
ANDROIDAUDIO_ResumeDevices();
|
||||||
|
OPENSLES_ResumeDevices();
|
||||||
|
AAUDIO_ResumeDevices();
|
||||||
|
Android_PausedAudio = SDL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Android_OnPause(void)
|
static void Android_OnPause(void)
|
||||||
{
|
{
|
||||||
SDL_OnApplicationWillEnterBackground();
|
SDL_OnApplicationWillEnterBackground();
|
||||||
|
@ -117,10 +135,7 @@ static void Android_OnPause(void)
|
||||||
|
|
||||||
if (Android_BlockOnPause) {
|
if (Android_BlockOnPause) {
|
||||||
/* We're blocking, also pause audio */
|
/* We're blocking, also pause audio */
|
||||||
ANDROIDAUDIO_PauseDevices();
|
Android_PauseAudio();
|
||||||
OPENSLES_PauseDevices();
|
|
||||||
AAUDIO_PauseDevices();
|
|
||||||
Android_PausedAudio = SDL_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Android_Paused = SDL_TRUE;
|
Android_Paused = SDL_TRUE;
|
||||||
|
@ -132,11 +147,7 @@ static void Android_OnResume(void)
|
||||||
|
|
||||||
SDL_OnApplicationWillEnterForeground();
|
SDL_OnApplicationWillEnterForeground();
|
||||||
|
|
||||||
if (Android_PausedAudio) {
|
Android_ResumeAudio();
|
||||||
ANDROIDAUDIO_ResumeDevices();
|
|
||||||
OPENSLES_ResumeDevices();
|
|
||||||
AAUDIO_ResumeDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||||
|
@ -162,6 +173,9 @@ static void Android_OnLowMemory(void)
|
||||||
|
|
||||||
static void Android_OnDestroy(void)
|
static void Android_OnDestroy(void)
|
||||||
{
|
{
|
||||||
|
/* Make sure we unblock any audio processing before we quit */
|
||||||
|
Android_ResumeAudio();
|
||||||
|
|
||||||
/* Discard previous events. The user should have handled state storage
|
/* Discard previous events. The user should have handled state storage
|
||||||
* in SDL_EVENT_WILL_ENTER_BACKGROUND. After nativeSendQuit() is called, no
|
* in SDL_EVENT_WILL_ENTER_BACKGROUND. After nativeSendQuit() is called, no
|
||||||
* events other than SDL_EVENT_QUIT and SDL_EVENT_TERMINATING should fire */
|
* events other than SDL_EVENT_QUIT and SDL_EVENT_TERMINATING should fire */
|
||||||
|
@ -212,7 +226,8 @@ void Android_PumpEvents(Sint64 timeoutNS)
|
||||||
SDL_AndroidLifecycleEvent event;
|
SDL_AndroidLifecycleEvent event;
|
||||||
SDL_bool paused = Android_Paused;
|
SDL_bool paused = Android_Paused;
|
||||||
|
|
||||||
while (Android_WaitLifecycleEvent(&event, GetLifecycleEventTimeout(paused, timeoutNS))) {
|
while (!Android_Destroyed &&
|
||||||
|
Android_WaitLifecycleEvent(&event, GetLifecycleEventTimeout(paused, timeoutNS))) {
|
||||||
Android_HandleLifecycleEvent(event);
|
Android_HandleLifecycleEvent(event);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue