adapter: setup control and notify

This commit is contained in:
Wim Taymans 2019-07-03 11:00:55 +02:00
parent 94e7be1845
commit cb6b8e0d17
2 changed files with 13 additions and 29 deletions

View file

@ -140,8 +140,7 @@ struct impl {
uint32_t n_buffers; uint32_t n_buffers;
struct pw_memblock *mem; struct pw_memblock *mem;
struct pw_control_link control; uint8_t control_buffer[1024];
struct pw_control_link notify;
}; };
/** \endcond */ /** \endcond */
@ -207,39 +206,25 @@ next:
static void try_link_controls(struct impl *impl) static void try_link_controls(struct impl *impl)
{ {
struct pw_control *cin, *cout;
struct pw_port *target, *port;
int res; int res;
if (!impl->use_converter) if (!impl->use_converter)
return; return;
if (impl->control.valid || impl->notify.valid)
return;
target = pw_node_find_port(impl->this, impl->direction, 0); if ((res = spa_node_port_set_io(impl->slave_node,
impl->direction, 0,
if (target == NULL) { SPA_IO_Notify,
pw_log_warn(NAME " %p: can't link controls", &impl->this); impl->control_buffer, sizeof(impl->control_buffer))) < 0) {
return; pw_log_warn(NAME " %p: set Notify on slave failed %d %s", impl,
res, spa_strerror(res));
} }
if ((res = spa_node_port_set_io(impl->adapter,
port = impl->slave_port; SPA_DIRECTION_REVERSE(impl->direction), 0,
SPA_IO_Control,
pw_log_debug(NAME " %p: trying controls", impl); impl->control_buffer, sizeof(impl->control_buffer))) < 0) {
spa_list_for_each(cout, &port->control_list[SPA_DIRECTION_OUTPUT], port_link) { pw_log_warn(NAME " %p: set Control on adapter failed %d %s", impl,
spa_list_for_each(cin, &target->control_list[SPA_DIRECTION_INPUT], port_link) { res, spa_strerror(res));
if ((res = pw_control_add_link(cout, 0, cin, 0, &impl->control)) < 0)
pw_log_error("failed to link controls: %s", spa_strerror(res));
break;
}
}
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 ((res = pw_control_add_link(cout, 0, cin, 0, &impl->notify)) < 0)
pw_log_error("failed to link controls: %s", spa_strerror(res));
break;
}
} }
} }

View file

@ -83,7 +83,6 @@ pw_control_new(struct pw_core *core,
spa_list_append(&port->control_list[direction], &this->port_link); spa_list_append(&port->control_list[direction], &this->port_link);
pw_port_emit_control_added(port, this); pw_port_emit_control_added(port, this);
} }
return this; return this;
error_exit: error_exit: