interfaces: improve remote API

Add return values to events and method callbacks. This makes it
possible to pass any error or async return value.
Add sync/done/error in both directions so that both proxy and resource
and perform/reply sync and produce errors.
Return a SPA_ASYNC from remote method calls (and events), keep the
sequence number in the connection.
With the core sync/done we can remove the client-node done method and
it's internal sequence number along with the seq number in method calls.
We can also use the method/event async return value to perform a sync
with as the unique sequence number for this method.
Add sync method and done/error event to proxy and resource.
This commit is contained in:
Wim Taymans 2019-02-18 12:31:36 +01:00
parent 0d8821096a
commit eea062ee53
41 changed files with 1180 additions and 817 deletions

View file

@ -281,11 +281,10 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
if ((res = spa_node_send_command(impl->cnode, command)) < 0)
return res;
}
return 0;
return res;
}
static void adapter_port_info(void *data,
static int adapter_port_info(void *data,
enum spa_direction direction, uint32_t port_id,
const struct spa_port_info *info)
{
@ -297,6 +296,7 @@ static void adapter_port_info(void *data,
this->callbacks->port_info(this->callbacks_data, direction, port_id, info);
}
}
return 0;
}
static const struct spa_node_callbacks adapter_node_callbacks = {
@ -326,6 +326,20 @@ impl_node_set_callbacks(struct spa_node *node,
return 0;
}
static int
impl_node_sync(struct spa_node *node, uint32_t seq)
{
struct node *this;
struct impl *impl;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct node, node);
impl = this->impl;
return spa_node_sync(impl->cnode, seq);
}
static int
impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
{
@ -816,11 +830,12 @@ static int impl_node_process(struct spa_node *node)
static const struct spa_node impl_node = {
SPA_VERSION_NODE,
.set_callbacks = impl_node_set_callbacks,
.sync = impl_node_sync,
.enum_params = impl_node_enum_params,
.set_param = impl_node_set_param,
.set_io = impl_node_set_io,
.send_command = impl_node_send_command,
.set_callbacks = impl_node_set_callbacks,
.add_port = impl_node_add_port,
.remove_port = impl_node_remove_port,
.port_enum_params = impl_node_port_enum_params,
@ -1077,7 +1092,7 @@ static void client_node_async_complete(void *data, uint32_t seq, int res)
struct node *node = &impl->node;
pw_log_debug("client-stream %p: async complete %d %d", &impl->this, seq, res);
node->callbacks->done(node->callbacks_data, seq, res);
node->callbacks->done(node->callbacks_data, seq);
}
static void client_node_active_changed(void *data, bool active)