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
This commit is contained in:
Wim Taymans 2021-07-26 11:48:00 +02:00
parent 78f52a7073
commit 9f6890e10e

View file

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