From f7eafe1404d42088493ac5623204e0c0b5648247 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 25 Oct 2021 17:52:39 +0200 Subject: [PATCH] stream: use user param field to track param changes count the number of changes and then when there are any, flip the SERIAL bit in the param info so that the server can detect a change. Without this, 2 updated params would not flip the bit and the param changes would not be noticed. --- src/pipewire/stream.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index c9c000177..16357e12f 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -258,14 +258,13 @@ static struct param *add_param(struct stream *impl, if ((idx = get_param_index(id)) != -1) { impl->info.change_mask |= SPA_NODE_CHANGE_MASK_PARAMS; - impl->params[idx].flags ^= SPA_PARAM_INFO_SERIAL; impl->params[idx].flags |= SPA_PARAM_INFO_READ; + impl->params[idx].user++; } else if ((idx = get_port_param_index(id)) != -1) { impl->port_info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS; - impl->port_params[idx].flags ^= SPA_PARAM_INFO_SERIAL; impl->port_params[idx].flags |= SPA_PARAM_INFO_READ; + impl->port_params[idx].user++; } - return p; } @@ -566,21 +565,41 @@ static int impl_send_command(void *object, const struct spa_command *command) static void emit_node_info(struct stream *d, bool full) { + uint32_t i; uint64_t old = full ? d->info.change_mask : 0; if (full) d->info.change_mask = d->change_mask_all; - if (d->info.change_mask != 0) + if (d->info.change_mask != 0) { + if (d->info.change_mask & SPA_NODE_CHANGE_MASK_PARAMS) { + for (i = 0; i < d->info.n_params; i++) { + if (d->params[i].user > 0) { + d->params[i].flags ^= SPA_PARAM_INFO_SERIAL; + d->params[i].user = 0; + } + } + } spa_node_emit_info(&d->hooks, &d->info); + } d->info.change_mask = old; } static void emit_port_info(struct stream *d, bool full) { + uint32_t i; uint64_t old = full ? d->port_info.change_mask : 0; if (full) d->port_info.change_mask = d->port_change_mask_all; - if (d->port_info.change_mask != 0) + if (d->port_info.change_mask != 0) { + if (d->port_info.change_mask & SPA_PORT_CHANGE_MASK_PARAMS) { + for (i = 0; i < d->port_info.n_params; i++) { + if (d->port_params[i].user > 0) { + d->port_params[i].flags ^= SPA_PARAM_INFO_SERIAL; + d->port_params[i].user = 0; + } + } + } spa_node_emit_port_info(&d->hooks, d->direction, 0, &d->port_info); + } d->port_info.change_mask = old; }