pulseaudio: Redesigned to use pa_threaded_mainloop.

We weren't meant to have multiple contexts and mainloops, but we had one
for each opened device and the hotplug detection thread. Instead, use
pa_threaded_mainloop, which can be shared between threads and objects, and
a single context (which, according to the PulseAudio documentation, is
usually meant to be a singleton that represents a global server connection,
possibly with multiple streams hung on it).

Now instead of polling in a loop, threads will block until the
threaded_mainloop runs a callback, and the callback will fire a signal to
unblock the thread.

Prior to this, the code upset ThreadSanitizer, as Pulse has some unprotected
global resource that each mainloop/context would touch.

Reference Issue #7427.
This commit is contained in:
Ryan C. Gordon
2023-05-24 13:36:52 -04:00
parent 81fe505c31
commit 35292d7dba
2 changed files with 269 additions and 214 deletions
File diff suppressed because it is too large Load Diff
-2
View File
@@ -32,8 +32,6 @@ struct SDL_PrivateAudioData
char *device_name;
/* pulseaudio structures */
pa_mainloop *mainloop;
pa_context *context;
pa_stream *stream;
/* Raw mixing buffer */