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.
This commit is contained in:
Wim Taymans 2023-09-07 14:16:50 +02:00
parent 7c7dea890b
commit c5f188784d
2 changed files with 10 additions and 12 deletions

View file

@ -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,

View file

@ -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,