From 4426da6a6235017d81aa4aa69cd6ad5c1392ec66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 Jan 2022 01:53:27 +0100 Subject: [PATCH] pulse-server: client: remove `disconnecting` flag When the `disconnecting` flag was first added in d44fdabea1c6d3b7beba633877d70541ec5cf8c6, a client's streams were not explicitly destroyed when it was freed, instead, only the client's pw_core was disconnected, which then caused all related streams to be destroyed. Thus there needed to be a way to determine why the stream's state changed to PW_STREAM_STATE_UNCONNECTED as it may have been because the client is disconnecting or because the stream has been "killed" in some other way. The `COMMAND_{PLAYBACK,RECORD}_STREAM_KILLED` command only needed to be sent to the client in the second case. However, at the moment, all streams of a client are explicitly destroyed before it's pw_core is disconnected. This makes the `disconnecting` flag unnecessary, thus it can be removed. --- src/modules/module-protocol-pulse/client.c | 4 +--- src/modules/module-protocol-pulse/client.h | 1 - src/modules/module-protocol-pulse/pulse-server.c | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/module-protocol-pulse/client.c b/src/modules/module-protocol-pulse/client.c index 77e9ffc22..b7d8f42f4 100644 --- a/src/modules/module-protocol-pulse/client.c +++ b/src/modules/module-protocol-pulse/client.c @@ -167,10 +167,8 @@ void client_free(struct client *client) spa_list_consume(o, &client->operations, link) operation_free(o); - if (client->core) { - client->disconnecting = true; + if (client->core) pw_core_disconnect(client->core); - } pw_map_clear(&client->streams); diff --git a/src/modules/module-protocol-pulse/client.h b/src/modules/module-protocol-pulse/client.h index 7ab5c26fc..d93445840 100644 --- a/src/modules/module-protocol-pulse/client.h +++ b/src/modules/module-protocol-pulse/client.h @@ -95,7 +95,6 @@ struct client { struct spa_list pending_streams; unsigned int disconnect:1; - unsigned int disconnecting:1; unsigned int new_msg_since_last_flush:1; unsigned int authenticated:1; diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index fb06bb8b0..c55dd12c9 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -994,7 +994,7 @@ static void stream_state_changed(void *data, enum pw_stream_state old, case PW_STREAM_STATE_UNCONNECTED: if (stream->create_tag != SPA_ID_INVALID) reply_error(client, -1, stream->create_tag, -ENOENT); - else if (!client->disconnecting) + else stream->killed = true; stream->done = true; break;