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.
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
The 3DS audio driver provides its own implementation for
SDL_LockAudio()
andSDL_UnlockAudio()
which does not use themixer_lock
of theSDL_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.