client-stream: emit property change events

Emit a property (param) change event when the volume or mute is
changed on a stream.
This commit is contained in:
Wim Taymans 2019-03-14 16:40:17 +01:00
parent 306f0dd964
commit 3fb9fa06a9
2 changed files with 52 additions and 33 deletions

View file

@ -521,20 +521,23 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
struct spa_pod_prop *prop;
struct spa_pod_object *obj = (struct spa_pod_object *) param;
struct props *p = &this->props;
int changed = 0;
SPA_POD_OBJECT_FOREACH(obj, prop) {
switch (prop->key) {
case SPA_PROP_volume:
spa_pod_get_float(&prop->value, &p->volume);
if (spa_pod_get_float(&prop->value, &p->volume) == 0)
changed++;
break;
case SPA_PROP_mute:
spa_pod_get_bool(&prop->value, &p->mute);
if (spa_pod_get_bool(&prop->value, &p->mute) == 0)
changed++;
break;
default:
break;
}
}
return 0;
return changed;
}
static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
@ -542,6 +545,16 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
return -ENOTSUP;
}
static void emit_info(struct impl *this, bool full)
{
if (full)
this->info.change_mask = this->info_all;
if (this->info.change_mask) {
spa_node_emit_info(&this->hooks, &this->info);
this->info.change_mask = 0;
}
}
static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
@ -553,7 +566,12 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
switch (id) {
case SPA_PARAM_Props:
return apply_props(this, param);
if (apply_props(this, param) > 0) {
this->info.change_mask = SPA_NODE_CHANGE_MASK_PARAMS;
this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
emit_info(this, false);
}
break;
default:
return -ENOENT;
}
@ -582,16 +600,6 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
return 0;
}
static void emit_info(struct impl *this, bool full)
{
if (full)
this->info.change_mask = this->info_all;
if (this->info.change_mask) {
spa_node_emit_info(&this->hooks, &this->info);
this->info.change_mask = 0;
}
}
static void emit_port_info(struct impl *this, struct port *port, bool full)
{
if (full)