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

@ -65,8 +65,8 @@ struct impl {
uint32_t dest_id;
uint8_t opcode;
struct spa_pod_builder builder;
struct pw_core *core;
uint32_t seq;
};
/** \endcond */
@ -398,16 +398,20 @@ pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection *
return &impl->builder;
}
void
int
pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
struct spa_pod_builder *builder)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t *p, size = builder->state.offset;
struct buffer *buf = &impl->out;
uint32_t seq;
if ((p = connection_ensure_size(conn, buf, 8 + size)) == NULL)
return;
return -ENOMEM;
seq = impl->seq;
impl->seq = (impl->seq + 1) & SPA_ASYNC_SEQ_MASK;
*p++ = impl->dest_id;
*p++ = (impl->opcode << 24) | (size & 0xffffff);
@ -418,8 +422,11 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
fprintf(stderr, ">>>>>>>>> out: %d %d %d\n", impl->dest_id, impl->opcode, size);
spa_debug_pod(0, NULL, (struct spa_pod *)p);
}
spa_hook_list_call(&conn->listener_list,
struct pw_protocol_native_connection_events, need_flush, 0);
return SPA_RESULT_RETURN_ASYNC(seq);
}
/** Flush the connection object