Skip to content

Commit

Permalink
coreaudio: Possibly fixed another shutdown race condition.
Browse files Browse the repository at this point in the history
Reference Issue #6159.
  • Loading branch information
icculus committed Sep 30, 2022
1 parent 7567c4c commit e6640ef
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/audio/coreaudio/SDL_coreaudio.m
Expand Up @@ -701,6 +701,14 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
}
#endif

/* if callback fires again, feed silence; don't call into the app. */
SDL_AtomicSet(&this->paused, 1);

if (this->hidden->thread) {
SDL_assert(SDL_AtomicGet(&this->shutdown) != 0); /* should have been set by SDL_audio.c */
SDL_WaitThread(this->hidden->thread, NULL);
}

if (iscapture) {
open_capture_devices--;
} else {
Expand All @@ -725,18 +733,10 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
open_devices = NULL;
}

/* if callback fires again, feed silence; don't call into the app. */
SDL_AtomicSet(&this->paused, 1);

if (this->hidden->audioQueue) {
AudioQueueDispose(this->hidden->audioQueue, 1);
}

if (this->hidden->thread) {
SDL_assert(SDL_AtomicGet(&this->shutdown) != 0); /* should have been set by SDL_audio.c */
SDL_WaitThread(this->hidden->thread, NULL);
}

if (this->hidden->ready_semaphore) {
SDL_DestroySemaphore(this->hidden->ready_semaphore);
}
Expand Down

0 comments on commit e6640ef

Please sign in to comment.