devkitPro / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
15 stars 12 forks source link

3DS LockAudio/UnlockAudio fails guaranteed conditions #13

Closed StephenCWills closed 1 year ago

StephenCWills commented 3 years ago

The SDL_audio.h header specifies a guarantee that the callback function must not be running while the audio lock is taken.

https://github.com/devkitPro/SDL/blob/a9a6d223b4ceb1618053f9e1e6ef5afbbf4f7335/include/SDL_audio.h#L260-L270

During a LockAudio/UnlockAudio pair, you can be guaranteed that the callback function is not running.

The 3DS audio driver provides its own implementation for SDL_LockAudio() and SDL_UnlockAudio() which does not use the mixer_lock of the SDL_AudioDevice so it does not provide this guarantee. This situation is leading to race conditions in SDL_audiolib and, subsequently, crashes in the latest version of DevilutionX.

WinterMute commented 1 year ago

closed by https://github.com/devkitPro/SDL/commit/a6611106d5d15900d421e718b0c9743231ee9d83