From 9f6890e10e1e9a121f5e58853fde96d81239bc6d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 26 Jul 2021 11:48:00 +0200 Subject: [PATCH] pulse-server: improve stream cleanup First disconnect the stream this ensures no more process events are called. Then flush out the pending events, then destroy the stream. Fixes #1451 --- src/modules/module-protocol-pulse/stream.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/module-protocol-pulse/stream.c b/src/modules/module-protocol-pulse/stream.c index a753a9b7e..87115bc71 100644 --- a/src/modules/module-protocol-pulse/stream.c +++ b/src/modules/module-protocol-pulse/stream.c @@ -56,17 +56,18 @@ void stream_free(struct stream *stream) if (stream->killed) stream_send_killed(stream); - /* force processing of all pending messages before we destroy - * the stream */ - pw_loop_invoke(impl->loop, NULL, 0, NULL, 0, false, client); - - if (stream->channel != SPA_ID_INVALID) - pw_map_remove(&client->streams, stream->channel); - if (stream->stream) { spa_hook_remove(&stream->stream_listener); + pw_stream_disconnect(stream->stream); + + /* force processing of all pending messages before we destroy + * the stream */ + pw_loop_invoke(impl->loop, NULL, 0, NULL, 0, false, client); + pw_stream_destroy(stream->stream); } + if (stream->channel != SPA_ID_INVALID) + pw_map_remove(&client->streams, stream->channel); pw_work_queue_cancel(impl->work_queue, stream, SPA_ID_INVALID);