-
Rafael Kitover authored
On SoundSDL destructor and `reset()`, there was a deadlock with Linux pthreads, it happened sometimes that the reader thread would call `SDL_SemWait(data_available)` while `deinit()` would destroy the semaphore and the `SDL_SemWait()` would end up waiting forever on a null semaphore. Change the sequencing of deinit() to prevent this from happening, set `initialized = false` at the beginning of the sequence to prevent subsequent entries into the reader callback, and add an SDL_Delay(100) between the final `SDL_SemPost()` and `SDL_UnlockMutex()`s and the `SDL_DestroySemaphore()` and `SDL_DestroyMutex()`s to allow a running reader to complete with a valid mutex and semaphores before they are destroyed and the thread is joined. Resetting the sound system also sometimes triggers a memory corruption bug, but that's a separate issue.
e9a86c54