AAudio: add aaudio pause/resume function to android events loop

This commit is contained in:
Sylvain 2021-04-15 21:16:10 +02:00
parent 02b1ebc9e0
commit b4f89c56c6
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E

View File

@ -48,6 +48,16 @@ static void openslES_ResumeDevices(void) {}
static void openslES_PauseDevices(void) {} static void openslES_PauseDevices(void) {}
#endif #endif
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO
extern void aaudio_ResumeDevices(void);
extern void aaudio_PauseDevices(void);
#else
static void aaudio_ResumeDevices(void) {}
static void aaudio_PauseDevices(void) {}
#endif
/* Number of 'type' events in the event queue */ /* Number of 'type' events in the event queue */
static int static int
SDL_NumberOfEvents(Uint32 type) SDL_NumberOfEvents(Uint32 type)
@ -110,6 +120,7 @@ Android_PumpEvents_Blocking(_THIS)
ANDROIDAUDIO_PauseDevices(); ANDROIDAUDIO_PauseDevices();
openslES_PauseDevices(); openslES_PauseDevices();
aaudio_PauseDevices();
if (SDL_SemWait(Android_ResumeSem) == 0) { if (SDL_SemWait(Android_ResumeSem) == 0) {
@ -122,6 +133,7 @@ Android_PumpEvents_Blocking(_THIS)
ANDROIDAUDIO_ResumeDevices(); ANDROIDAUDIO_ResumeDevices();
openslES_ResumeDevices(); openslES_ResumeDevices();
aaudio_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)) {
@ -178,6 +190,7 @@ Android_PumpEvents_NonBlocking(_THIS)
if (videodata->pauseAudio) { if (videodata->pauseAudio) {
ANDROIDAUDIO_PauseDevices(); ANDROIDAUDIO_PauseDevices();
openslES_PauseDevices(); openslES_PauseDevices();
aaudio_PauseDevices();
} }
backup_context = 0; backup_context = 0;
@ -196,6 +209,7 @@ Android_PumpEvents_NonBlocking(_THIS)
if (videodata->pauseAudio) { if (videodata->pauseAudio) {
ANDROIDAUDIO_ResumeDevices(); ANDROIDAUDIO_ResumeDevices();
openslES_ResumeDevices(); openslES_ResumeDevices();
aaudio_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 */