Răsfoiți Sursa

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.
Ryan C. Gordon 1 an în urmă
părinte
comite
81fe505c31
1 a modificat fișierele cu 4 adăugiri și 21 ștergeri
  1. 4 21
      src/audio/SDL_audio.c

+ 4 - 21
src/audio/SDL_audio.c

@@ -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)