coreaudio: Possibly fixed another shutdown race condition. Reference Issue #6159.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 1a68719..63ce6a5 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -701,6 +701,14 @@ COREAUDIO_CloseDevice(_THIS)
}
#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 {
@@ -725,18 +733,10 @@ COREAUDIO_CloseDevice(_THIS)
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);
}