audio: remove is_in_audio_device_thread()

SDL mutexes are always recursive in modern times, so no need to check this,
plus the test triggers a false-positive on ThreadSanitizer.

Reference Issue #7427.
main
Ryan C. Gordon 2023-05-24 13:34:28 -04:00
parent d4bc393efe
commit 81fe505c31
1 changed files with 4 additions and 21 deletions

View File

@ -182,31 +182,14 @@ static int SDL_AudioOpenDevice_Default(SDL_AudioDevice *_this, const char *devna
return SDL_Unsupported();
}
static SDL_INLINE SDL_bool is_in_audio_device_thread(SDL_AudioDevice *device)
static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device)
{
/* The device thread locks the same mutex, but not through the public API.
This check is in case the application, in the audio callback,
tries to lock the thread that we've already locked from the
device thread...just in case we only have non-recursive mutexes. */
if (device->thread && (SDL_ThreadID() == device->threadid)) {
return SDL_TRUE;
}
return SDL_FALSE;
SDL_LockMutex(device->mixer_lock);
}
static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang assumes recursive locks */
static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device)
{
if (!is_in_audio_device_thread(device)) {
SDL_LockMutex(device->mixer_lock);
}
}
static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang assumes recursive locks */
{
if (!is_in_audio_device_thread(device)) {
SDL_UnlockMutex(device->mixer_lock);
}
SDL_UnlockMutex(device->mixer_lock);
}
static void finish_audio_entry_points_init(void)