control: keep track of prop_id

Keep track of the property id which describes the property
functionality.
Link controls based on the property instead of the param_id.
This commit is contained in:
Wim Taymans 2018-02-07 17:56:35 +01:00
parent 053f251be8
commit 2fe6a8245d
3 changed files with 19 additions and 9 deletions

View file

@ -148,15 +148,24 @@ static void try_link_controls(struct impl *impl, struct pw_port *port, struct pw
struct pw_control *cin, *cout;
int res;
pw_log_debug("module %p: trying controls", impl);
spa_list_for_each(cout, &port->control_list[SPA_DIRECTION_OUTPUT], port_link) {
spa_list_for_each(cin, &target->control_list[SPA_DIRECTION_INPUT], port_link) {
pw_log_debug("controls %d <-> %d", cin->id, cout->id);
if (cin->id == cout->id) {
if (cin->prop_id == cout->prop_id) {
if ((res = pw_control_link(cout, cin)) < 0)
pw_log_error("failed to link controls: %s", spa_strerror(res));
}
}
}
spa_list_for_each(cin, &port->control_list[SPA_DIRECTION_INPUT], port_link) {
spa_list_for_each(cout, &target->control_list[SPA_DIRECTION_OUTPUT], port_link) {
if (cin->prop_id == cout->prop_id) {
if ((res = pw_control_link(cout, cin)) < 0)
pw_log_error("failed to link controls: %s", spa_strerror(res));
}
}
}
}

View file

@ -50,10 +50,11 @@ pw_control_new(struct pw_core *core,
if (spa_pod_object_parse(param,
":", t->param_io.id, "I", &this->id,
":", t->param_io.size, "i", &this->size) < 0)
":", t->param_io.size, "i", &this->size,
":", t->param.propId, "I", &this->prop_id) < 0)
goto exit_free;
pw_log_debug("control %p: new %s %d", this, spa_type_map_get_type(t->map, this->id), direction);
pw_log_debug("control %p: new %s %d", this, spa_type_map_get_type(t->map, this->prop_id), direction);
this->core = core;
this->port = port;
@ -78,7 +79,6 @@ pw_control_new(struct pw_core *core,
exit_free:
free(impl);
exit:
pw_log_error("control failed");
return NULL;
}
@ -154,7 +154,8 @@ int pw_control_link(struct pw_control *control, struct pw_control *other)
impl = SPA_CONTAINER_OF(control, struct impl, this);
pw_log_debug("control %p: link to %p", control, other);
pw_log_debug("control %p: link to %p %s", control, other,
spa_type_map_get_type(control->core->type.map, control->prop_id));
if (impl->mem == NULL) {
if ((res = pw_memblock_alloc(PW_MEMBLOCK_FLAG_WITH_FD |
@ -224,7 +225,7 @@ int pw_control_unlink(struct pw_control *control, struct pw_control *other)
if ((res = spa_node_port_set_io(port->node->node,
port->direction, port->port_id,
control->id, NULL, 0)) < 0) {
goto exit;
pw_log_warn("control %p: can't unset port control io", control);
}
}
@ -233,13 +234,12 @@ int pw_control_unlink(struct pw_control *control, struct pw_control *other)
if ((res = spa_node_port_set_io(port->node->node,
port->direction, port->port_id,
other->id, NULL, 0)) < 0) {
goto exit;
pw_log_warn("control %p: can't unset port control io", control);
}
}
spa_hook_list_call(&control->listener_list, struct pw_control_events, unlinked, other);
spa_hook_list_call(&other->listener_list, struct pw_control_events, unlinked, control);
exit:
return res;
}

View file

@ -424,6 +424,7 @@ struct pw_control {
struct spa_list inputs_link; /**< link in linked input control */
uint32_t id;
uint32_t prop_id;
int32_t size;
struct spa_hook_list listener_list;