From 722e646f90fecf96e76befe97ba08ae351922db5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Jun 2024 18:20:51 +0200 Subject: [PATCH] impl-node: add backwards compat for old clients Bump the client-node version to 6. Older clients expect the server to prepare the activation counters so make a flag to do that. --- src/modules/module-client-node/client-node.c | 7 +++++++ src/pipewire/extensions/client-node.h | 7 ++++++- src/pipewire/impl-node.c | 21 +++++++++++--------- src/pipewire/private.h | 1 + 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index ee281478d..a2db94f46 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -1799,6 +1799,13 @@ struct pw_impl_client_node *pw_impl_client_node_new(struct pw_resource *resource this->node->remote = true; this->flags = 0; + if (resource->version < 5) { + pw_log_warn("using server side driver for old client version %d", resource->version); + } + if (resource->version < 6) { + this->node->server_prepare = true; + pw_log_warn("using server side prepare for old client version %d", resource->version); + } pw_resource_add_listener(this->resource, &impl->resource_listener, diff --git a/src/pipewire/extensions/client-node.h b/src/pipewire/extensions/client-node.h index abcd6b699..285479688 100644 --- a/src/pipewire/extensions/client-node.h +++ b/src/pipewire/extensions/client-node.h @@ -22,7 +22,12 @@ extern "C" { */ #define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode" -#define PW_VERSION_CLIENT_NODE 5 +/* + * version 4: new port_set_mix_info event added + * version 5: driver nodes are scheduled on the client + * version 6: nodes activate peer links themselves when ready + */ +#define PW_VERSION_CLIENT_NODE 6 struct pw_client_node; #define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node" diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 0440c833d..45524e7b6 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -154,17 +154,19 @@ do_node_prepare(struct spa_loop *loop, bool async, uint32_t seq, if (this->rt.prepared) return 0; - /* clear the eventfd in case it was written to while the node was stopped */ - res = spa_system_eventfd_read(this->rt.target.system, this->source.fd, &dummy); - if (SPA_UNLIKELY(res != -EAGAIN && res != 0)) - pw_log_warn("%p: read failed %m", this); + if (!this->server_prepare) { + /* clear the eventfd in case it was written to while the node was stopped */ + res = spa_system_eventfd_read(this->rt.target.system, this->source.fd, &dummy); + if (SPA_UNLIKELY(res != -EAGAIN && res != 0)) + pw_log_warn("%p: read failed %m", this); + spa_loop_add_source(loop, &this->source); + } SPA_ATOMIC_STORE(this->rt.target.activation->status, PW_NODE_ACTIVATION_FINISHED); - spa_loop_add_source(loop, &this->source); spa_list_for_each(t, &this->rt.target_list, link) { /* we can now trigger ourself */ - if (t->id == this->info.id) + if (t->id == this->info.id || this->server_prepare) activate_target(this, t); } @@ -200,7 +202,8 @@ do_node_unprepare(struct spa_loop *loop, bool async, uint32_t seq, spa_list_for_each(t, &this->rt.target_list, link) deactivate_target(this, t, trigger); - spa_loop_remove_source(loop, &this->source); + if (!this->server_prepare) + spa_loop_remove_source(loop, &this->source); this->rt.prepared = false; return 0; @@ -208,7 +211,7 @@ do_node_unprepare(struct spa_loop *loop, bool async, uint32_t seq, static void add_node_to_graph(struct pw_impl_node *node) { - if (node->remote) + if (node->remote && !node->server_prepare) return; pw_loop_invoke(node->data_loop, do_node_prepare, 1, NULL, 0, true, node); @@ -216,7 +219,7 @@ static void add_node_to_graph(struct pw_impl_node *node) static void remove_node_from_graph(struct pw_impl_node *node) { - if (node->remote) + if (node->remote && !node->server_prepare) return; pw_loop_invoke(node->data_loop, do_node_unprepare, 1, NULL, 0, true, node); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 05cc5418c..fc725393f 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -740,6 +740,7 @@ struct pw_impl_node { unsigned int sync:1; /**< the sync-groups are active */ unsigned int transport:1; /**< the transport is active */ unsigned int async:1; /**< async processing, one cycle latency */ + unsigned int server_prepare:1; /**< prepare links server side for old clients */ uint32_t port_user_data_size; /**< extra size for port user data */