diff --git a/client/audiodevs/PipeWire/pipewire.c b/client/audiodevs/PipeWire/pipewire.c index 03e41f84..6604ff1e 100644 --- a/client/audiodevs/PipeWire/pipewire.c +++ b/client/audiodevs/PipeWire/pipewire.c @@ -104,30 +104,11 @@ err_context: pw_context_destroy(context); err: + pw_loop_destroy(pw.loop); pw_deinit(); return false; } -static void pipewire_free(void) -{ - if (pw.thread) - { - pw_thread_loop_lock(pw.thread); - if (pw.stream) - { - pw_stream_destroy(pw.stream); - pw.stream = NULL; - } - - pw_thread_loop_signal(pw.thread, true); - pw_thread_loop_destroy(pw.thread); - pw.loop = NULL; - } - - ringbuffer_free(&pw.buffer); - pw_deinit(); -} - static void pipewire_stop_stream(void) { if (!pw.stream) @@ -140,6 +121,20 @@ static void pipewire_stop_stream(void) pw_thread_loop_unlock(pw.thread); } +static void pipewire_free(void) +{ + pipewire_stop_stream(); + pw_thread_loop_stop(pw.thread); + pw_thread_loop_destroy(pw.thread); + pw_loop_destroy(pw.loop); + + pw.loop = NULL; + pw.thread = NULL; + + ringbuffer_free(&pw.buffer); + pw_deinit(); +} + static void pipewire_start(int channels, int sampleRate) { const struct spa_pod * params[1];