pulseaudio: Stop the threaded mainloop before destroying the context.

Otherwise, we might trigger an assertion in libpulse.

Reference Issue #8348.

(cherry picked from commit 10fab3a39e2bd163cc45147b6afd517501801002)
This commit is contained in:
Ryan C. Gordon 2023-10-11 14:31:37 -04:00
parent 2849ca404e
commit d8b34b0993
No known key found for this signature in database
GPG key ID: FA148B892AB48044

View file

@ -286,13 +286,15 @@ static void WaitForPulseOperation(pa_operation *o)
static void DisconnectFromPulseServer(void) static void DisconnectFromPulseServer(void)
{ {
if (pulseaudio_threaded_mainloop != NULL) {
PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop);
}
if (pulseaudio_context) { if (pulseaudio_context) {
PULSEAUDIO_pa_context_disconnect(pulseaudio_context); PULSEAUDIO_pa_context_disconnect(pulseaudio_context);
PULSEAUDIO_pa_context_unref(pulseaudio_context); PULSEAUDIO_pa_context_unref(pulseaudio_context);
pulseaudio_context = NULL; pulseaudio_context = NULL;
} }
if (pulseaudio_threaded_mainloop != NULL) { if (pulseaudio_threaded_mainloop != NULL) {
PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop);
PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop); PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop);
pulseaudio_threaded_mainloop = NULL; pulseaudio_threaded_mainloop = NULL;
} }