mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-03 18:55:40 +00:00
androidaudio: same fix as AAudio for pausing thread when backgrounding app.
Reference Issue #8748.
This commit is contained in:
parent
109bb2f17e
commit
1e13aa2c98
|
@ -148,29 +148,12 @@ AudioBootStrap ANDROIDAUDIO_bootstrap = {
|
||||||
void ANDROIDAUDIO_PauseDevices(void)
|
void ANDROIDAUDIO_PauseDevices(void)
|
||||||
{
|
{
|
||||||
/* TODO: Handle multiple devices? */
|
/* TODO: Handle multiple devices? */
|
||||||
struct SDL_PrivateAudioData *private;
|
|
||||||
if (audioDevice && audioDevice->hidden) {
|
if (audioDevice && audioDevice->hidden) {
|
||||||
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
|
SDL_LockMutex(audioDevice->mixer_lock);
|
||||||
if (SDL_AtomicGet(&audioDevice->paused)) {
|
|
||||||
/* The device is already paused, leave it alone */
|
|
||||||
private->resume = SDL_FALSE;
|
|
||||||
} else {
|
|
||||||
SDL_LockMutex(audioDevice->mixer_lock);
|
|
||||||
SDL_AtomicSet(&audioDevice->paused, 1);
|
|
||||||
private->resume = SDL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (captureDevice && captureDevice->hidden) {
|
if (captureDevice && captureDevice->hidden) {
|
||||||
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
|
SDL_LockMutex(captureDevice->mixer_lock);
|
||||||
if (SDL_AtomicGet(&captureDevice->paused)) {
|
|
||||||
/* The device is already paused, leave it alone */
|
|
||||||
private->resume = SDL_FALSE;
|
|
||||||
} else {
|
|
||||||
SDL_LockMutex(captureDevice->mixer_lock);
|
|
||||||
SDL_AtomicSet(&captureDevice->paused, 1);
|
|
||||||
private->resume = SDL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,23 +161,12 @@ void ANDROIDAUDIO_PauseDevices(void)
|
||||||
void ANDROIDAUDIO_ResumeDevices(void)
|
void ANDROIDAUDIO_ResumeDevices(void)
|
||||||
{
|
{
|
||||||
/* TODO: Handle multiple devices? */
|
/* TODO: Handle multiple devices? */
|
||||||
struct SDL_PrivateAudioData *private;
|
|
||||||
if (audioDevice && audioDevice->hidden) {
|
if (audioDevice && audioDevice->hidden) {
|
||||||
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
|
SDL_UnlockMutex(audioDevice->mixer_lock);
|
||||||
if (private->resume) {
|
|
||||||
SDL_AtomicSet(&audioDevice->paused, 0);
|
|
||||||
private->resume = SDL_FALSE;
|
|
||||||
SDL_UnlockMutex(audioDevice->mixer_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (captureDevice && captureDevice->hidden) {
|
if (captureDevice && captureDevice->hidden) {
|
||||||
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
|
SDL_UnlockMutex(captureDevice->mixer_lock);
|
||||||
if (private->resume) {
|
|
||||||
SDL_AtomicSet(&captureDevice->paused, 0);
|
|
||||||
private->resume = SDL_FALSE;
|
|
||||||
SDL_UnlockMutex(captureDevice->mixer_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
|
|
||||||
struct SDL_PrivateAudioData
|
struct SDL_PrivateAudioData
|
||||||
{
|
{
|
||||||
/* Resume device if it was paused automatically */
|
int unused;
|
||||||
int resume;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ANDROIDAUDIO_ResumeDevices(void);
|
void ANDROIDAUDIO_ResumeDevices(void);
|
||||||
|
|
Loading…
Reference in a new issue