From c5f188784dc2349a9f8d7c68529ec67c543bcead Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 7 Sep 2023 14:16:50 +0200 Subject: [PATCH] impl-node: make sure we always clear params Always first clear the params before we start enumerating new ones. Otherwise we only clear them when we see the first result and there might not be a result. --- src/pipewire/impl-node.c | 11 +++++------ src/pipewire/impl-port.c | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index f75e29377..1c82d8e65 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -2133,7 +2133,6 @@ struct result_node_params_data { uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param); int seq; - uint32_t count; unsigned int cache:1; }; @@ -2147,11 +2146,8 @@ static void result_node_params(void *data, int seq, int res, uint32_t type, cons const struct spa_result_node_params *r = result; if (d->seq == seq) { d->callback(d->data, seq, r->id, r->index, r->next, r->param); - if (d->cache) { - if (d->count++ == 0) - pw_param_add(&impl->pending_list, seq, r->id, NULL); + if (d->cache) pw_param_add(&impl->pending_list, seq, r->id, r->param); - } } break; } @@ -2172,7 +2168,7 @@ int pw_impl_node_for_each_param(struct pw_impl_node *node, { int res; struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); - struct result_node_params_data user_data = { impl, data, callback, seq, 0, false }; + struct result_node_params_data user_data = { impl, data, callback, seq, false }; struct spa_hook listener; struct spa_param_info *pi; static const struct spa_node_events node_events = { @@ -2226,6 +2222,9 @@ int pw_impl_node_for_each_param(struct pw_impl_node *node, user_data.cache = impl->cache_params && (filter == NULL && index == 0 && max == UINT32_MAX); + if (user_data.cache) + pw_param_add(&impl->pending_list, seq, param_id, NULL); + spa_zero(listener); spa_node_add_listener(node->node, &listener, &node_events, &user_data); res = spa_node_enum_params(node->node, seq, diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 31b2af81b..add9e7aec 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -1368,7 +1368,6 @@ struct result_port_params_data { uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param); int seq; - uint32_t count; unsigned int cache:1; }; @@ -1382,11 +1381,8 @@ static void result_port_params(void *data, int seq, int res, uint32_t type, cons const struct spa_result_node_params *r = result; if (d->seq == seq) { d->callback(d->data, seq, r->id, r->index, r->next, r->param); - if (d->cache) { - if (d->count++ == 0) - pw_param_add(&impl->pending_list, seq, r->id, NULL); + if (d->cache) pw_param_add(&impl->pending_list, seq, r->id, r->param); - } } break; } @@ -1408,7 +1404,7 @@ int pw_impl_port_for_each_param(struct pw_impl_port *port, int res; struct impl *impl = SPA_CONTAINER_OF(port, struct impl, this); struct pw_impl_node *node = port->node; - struct result_port_params_data user_data = { impl, data, callback, seq, 0, false }; + struct result_port_params_data user_data = { impl, data, callback, seq, false }; struct spa_hook listener; struct spa_param_info *pi; static const struct spa_node_events node_events = { @@ -1462,6 +1458,9 @@ int pw_impl_port_for_each_param(struct pw_impl_port *port, user_data.cache = impl->cache_params && (filter == NULL && index == 0 && max == UINT32_MAX); + if (user_data.cache) + pw_param_add(&impl->pending_list, seq, param_id, NULL); + spa_zero(listener); spa_node_add_listener(node->node, &listener, &node_events, &user_data); res = spa_node_port_enum_params(node->node, seq,