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.
This commit is contained in:
Wim Taymans 2021-10-25 17:52:39 +02:00
parent eea6e7a1fb
commit f7eafe1404

View file

@ -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;
}