mirror of https://github.com/encounter/SDL.git
Fixed bug 5239 - Play audio on Android while backgrounded (Thanks Superfury)
Add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO not to pause audio when the app goes to background. (It requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
This commit is contained in:
parent
7ef188a1fb
commit
955f3184f9
|
@ -1028,6 +1028,18 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE"
|
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable to control whether SDL will pause audio in background
|
||||||
|
* (Requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
|
||||||
|
*
|
||||||
|
* The variable can be set to the following values:
|
||||||
|
* "0" - Non paused.
|
||||||
|
* "1" - Paused. (default)
|
||||||
|
*
|
||||||
|
* The value should be set before SDL is initialized.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO "SDL_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable to control whether the return key on the soft keyboard
|
* \brief A variable to control whether the return key on the soft keyboard
|
||||||
* should hide the soft keyboard on Android and iOS.
|
* should hide the soft keyboard on Android and iOS.
|
||||||
|
|
|
@ -175,8 +175,10 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||||
SDL_UnlockMutex(Android_ActivityMutex);
|
SDL_UnlockMutex(Android_ActivityMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (videodata->pauseAudio) {
|
||||||
ANDROIDAUDIO_PauseDevices();
|
ANDROIDAUDIO_PauseDevices();
|
||||||
openslES_PauseDevices();
|
openslES_PauseDevices();
|
||||||
|
}
|
||||||
|
|
||||||
backup_context = 0;
|
backup_context = 0;
|
||||||
}
|
}
|
||||||
|
@ -191,8 +193,10 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||||
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
|
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
|
||||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||||
|
|
||||||
|
if (videodata->pauseAudio) {
|
||||||
ANDROIDAUDIO_ResumeDevices();
|
ANDROIDAUDIO_ResumeDevices();
|
||||||
openslES_ResumeDevices();
|
openslES_ResumeDevices();
|
||||||
|
}
|
||||||
|
|
||||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||||
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
||||||
|
|
|
@ -181,6 +181,7 @@ Android_VideoInit(_THIS)
|
||||||
|
|
||||||
videodata->isPaused = SDL_FALSE;
|
videodata->isPaused = SDL_FALSE;
|
||||||
videodata->isPausing = SDL_FALSE;
|
videodata->isPausing = SDL_FALSE;
|
||||||
|
videodata->pauseAudio = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO, SDL_TRUE);
|
||||||
|
|
||||||
mode.format = Android_ScreenFormat;
|
mode.format = Android_ScreenFormat;
|
||||||
mode.w = Android_DeviceWidth;
|
mode.w = Android_DeviceWidth;
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef struct SDL_VideoData
|
||||||
SDL_Rect textRect;
|
SDL_Rect textRect;
|
||||||
int isPaused;
|
int isPaused;
|
||||||
int isPausing;
|
int isPausing;
|
||||||
|
int pauseAudio;
|
||||||
} SDL_VideoData;
|
} SDL_VideoData;
|
||||||
|
|
||||||
extern int Android_SurfaceWidth;
|
extern int Android_SurfaceWidth;
|
||||||
|
|
Loading…
Reference in New Issue