From 194c0f9c99ab383f6af3f2cc2b48c4d4c9c04a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 Jan 2022 02:07:07 +0100 Subject: [PATCH] pulse-server: stream: remove `done` flag When the `done` flag was first added in 9f9be7d7f2ee2fa464953e7a25a85bac18792241, it was actually needed because cleanup was implemented using a per-client eventfd which was signalled when something related to the particular client needed to be freed. The function that ran, then, checked each stream's `done` flag, and freed them as necessary. However, since c70a5de5266b878cb62cd0ac84fcf7a717146018, the stream cleanup is done using a work queue, and as a consequence, the `done` flag is no longer needed. --- src/modules/module-protocol-pulse/pulse-server.c | 12 +++++++----- src/modules/module-protocol-pulse/stream.h | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index c55dd12c9..98a23ec81 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -970,7 +970,7 @@ static void stream_control_info(void *data, uint32_t id, } } -static void on_stream_cleanup(void *obj, void *data, int res, uint32_t id) +static void do_destroy_stream(void *obj, void *data, int res, uint32_t id) { struct stream *stream = obj; struct client *client = stream->client; @@ -985,27 +985,29 @@ static void stream_state_changed(void *data, enum pw_stream_state old, struct stream *stream = data; struct client *client = stream->client; struct impl *impl = client->impl; + bool destroy_stream = false; switch (state) { case PW_STREAM_STATE_ERROR: reply_error(client, -1, stream->create_tag, -EIO); - stream->done = true; + destroy_stream = true; break; case PW_STREAM_STATE_UNCONNECTED: if (stream->create_tag != SPA_ID_INVALID) reply_error(client, -1, stream->create_tag, -ENOENT); else stream->killed = true; - stream->done = true; + destroy_stream = true; break; case PW_STREAM_STATE_CONNECTING: case PW_STREAM_STATE_PAUSED: case PW_STREAM_STATE_STREAMING: break; } - if (stream->done) { + + if (destroy_stream) { pw_work_queue_add(impl->work_queue, stream, 0, - on_stream_cleanup, client); + do_destroy_stream, NULL); } } diff --git a/src/modules/module-protocol-pulse/stream.h b/src/modules/module-protocol-pulse/stream.h index a7c4cc1e4..e79beb758 100644 --- a/src/modules/module-protocol-pulse/stream.h +++ b/src/modules/module-protocol-pulse/stream.h @@ -111,7 +111,6 @@ struct stream { unsigned int adjust_latency:1; unsigned int is_underrun:1; unsigned int in_prebuf:1; - unsigned int done:1; unsigned int killed:1; unsigned int pending:1; };