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

@ -146,8 +146,6 @@ struct node {
uint32_t n_params;
struct spa_pod **params;
uint32_t seq;
};
struct impl {
@ -396,9 +394,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
if (this->resource == NULL)
return 0;
pw_client_node_resource_set_param(this->resource, this->seq, id, flags, param);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
return pw_client_node_resource_set_param(this->resource, id, flags, param);
}
static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
@ -448,7 +444,6 @@ static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
{
struct node *this;
int res = 0;
spa_return_val_if_fail(node != NULL, -EINVAL);
spa_return_val_if_fail(command != NULL, -EINVAL);
@ -458,10 +453,8 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
if (this->resource == NULL)
return 0;
pw_client_node_resource_command(this->resource, this->seq, command);
res = SPA_RESULT_RETURN_ASYNC(this->seq++);
return res;
pw_log_debug("client-node %p: send command %d", node, SPA_COMMAND_TYPE(command));
return pw_client_node_resource_command(this->resource, command);
}
@ -497,6 +490,16 @@ 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;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct node, node);
pw_log_debug("client-node %p: sync %u", node, seq);
return pw_resource_sync(this->resource, seq);
}
static void
do_update_port(struct node *this,
struct port *port,
@ -585,11 +588,7 @@ impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t
spa_return_val_if_fail(CHECK_FREE_PORT(this, direction, port_id), -EINVAL);
pw_client_node_resource_add_port(this->resource,
this->seq,
direction, port_id);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
return pw_client_node_resource_add_port(this->resource, direction, port_id);
}
static int
@ -602,11 +601,7 @@ impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint3
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
pw_client_node_resource_remove_port(this->resource,
this->seq,
direction, port_id);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
return pw_client_node_resource_remove_port(this->resource, direction, port_id);
}
static int
@ -667,13 +662,14 @@ impl_node_port_set_param(struct spa_node *node,
if (this->resource == NULL)
return 0;
pw_client_node_resource_port_set_param(this->resource,
this->seq,
pw_log_debug("node %p: port %d.%d add param %s %d", this,
direction, port_id,
spa_debug_type_find_name(spa_type_param, id), id);
return pw_client_node_resource_port_set_param(this->resource,
direction, port_id,
id, flags,
param);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static int do_port_set_io(struct impl *impl,
@ -722,15 +718,12 @@ static int do_port_set_io(struct impl *impl,
update_io(this, mix->ios, id, memid);
pw_client_node_resource_port_set_io(this->resource,
this->seq,
return pw_client_node_resource_port_set_io(this->resource,
direction, port_id,
mix_id,
id,
memid,
mem_offset, mem_size);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static int
@ -855,12 +848,9 @@ do_port_use_buffers(struct impl *impl,
}
}
pw_client_node_resource_port_use_buffers(this->resource,
this->seq,
return pw_client_node_resource_port_use_buffers(this->resource,
direction, port_id, mix_id,
n_buffers, mb);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static int
@ -946,16 +936,7 @@ static int impl_node_process(struct spa_node *node)
return SPA_STATUS_OK;
}
static void
client_node_done(void *data, int seq, int res)
{
struct impl *impl = data;
struct node *this = &impl->node;
if (this->callbacks && this->callbacks->done)
this->callbacks->done(this->callbacks_data, seq, res);
}
static void
static int
client_node_update(void *data,
uint32_t change_mask,
uint32_t max_input_ports,
@ -988,9 +969,10 @@ client_node_update(void *data,
}
spa_log_debug(this->log, "node %p: got node update max_in %u, max_out %u", this,
this->max_inputs, this->max_outputs);
return 0;
}
static void
static int
client_node_port_update(void *data,
enum spa_direction direction,
uint32_t port_id,
@ -1006,7 +988,7 @@ client_node_port_update(void *data,
spa_log_debug(this->log, "node %p: got port update", this);
if (!CHECK_PORT_ID(this, direction, port_id))
return;
return -EINVAL;
remove = (change_mask == 0);
@ -1033,25 +1015,26 @@ client_node_port_update(void *data,
info && (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO))
this->callbacks->port_info(this->callbacks_data, direction, port_id, info);
}
return 0;
}
static void client_node_set_active(void *data, bool active)
static int client_node_set_active(void *data, bool active)
{
struct impl *impl = data;
pw_node_set_active(impl->this.node, active);
return pw_node_set_active(impl->this.node, active);
}
static void client_node_event(void *data, struct spa_event *event)
static int client_node_event(void *data, struct spa_event *event)
{
struct impl *impl = data;
struct node *this = &impl->node;
if (this->callbacks && this->callbacks->event)
this->callbacks->event(this->callbacks_data, event);
return 0;
}
static struct pw_client_node_proxy_methods client_node_methods = {
PW_VERSION_CLIENT_NODE_PROXY_METHODS,
.done = client_node_done,
.update = client_node_update,
.port_update = client_node_port_update,
.set_active = client_node_set_active,
@ -1082,11 +1065,12 @@ static void node_on_data_fd_events(struct spa_source *source)
static const struct spa_node impl_node = {
SPA_VERSION_NODE,
NULL,
.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,
@ -1133,9 +1117,7 @@ node_init(struct node *this,
this->data_source.mask = SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP;
this->data_source.rmask = 0;
this->seq = 1;
return SPA_RESULT_RETURN_ASYNC(this->seq++);
return 0;
}
static int node_clear(struct node *this)
@ -1186,6 +1168,25 @@ static void client_node_resource_destroy(void *data)
pw_node_destroy(this->node);
}
static void client_node_resource_error(void *data, int res, const char *message)
{
struct impl *impl = data;
struct node *this = &impl->node;
pw_log_error("client-node %p: error %d: %s", this, res, message);
if (this->callbacks && this->callbacks->error)
this->callbacks->error(this->callbacks_data, res, message);
}
static void client_node_resource_done(void *data, uint32_t seq)
{
struct impl *impl = data;
struct node *this = &impl->node;
pw_log_debug("client-node %p: done %d", this, seq);
if (this->callbacks && this->callbacks->done)
this->callbacks->done(this->callbacks_data, SPA_RESULT_ASYNC_SEQ(seq));
}
void pw_client_node_registered(struct pw_client_node *this, uint32_t node_id)
{
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
@ -1541,6 +1542,8 @@ static const struct pw_node_events node_events = {
static const struct pw_resource_events resource_events = {
PW_VERSION_RESOURCE_EVENTS,
.destroy = client_node_resource_destroy,
.error = client_node_resource_error,
.done = client_node_resource_done,
};
static int root_impl_process(void *data, struct spa_graph_node *node)
@ -1630,6 +1633,8 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
pw_node_add_listener(this->node, &impl->node_listener, &node_events, impl);
pw_resource_sync(this->resource, 0);
return this;
error_no_node:

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)

View file

@ -31,23 +31,7 @@
#include <extensions/protocol-native.h>
#include <extensions/client-node.h>
static void
client_node_marshal_done(void *object, int seq, int res)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Int(res));
pw_protocol_native_end_proxy(proxy, b);
}
static void
static int
client_node_marshal_update(void *object,
uint32_t change_mask,
uint32_t max_input_ports,
@ -83,10 +67,10 @@ client_node_marshal_update(void *object,
}
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void
static int
client_node_marshal_port_update(void *object,
enum spa_direction direction,
uint32_t port_id,
@ -133,10 +117,10 @@ client_node_marshal_port_update(void *object,
}
spa_pod_builder_pop(b, &f[0]);
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void client_node_marshal_set_active(void *object, bool active)
static int client_node_marshal_set_active(void *object, bool active)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -146,10 +130,10 @@ static void client_node_marshal_set_active(void *object, bool active)
spa_pod_builder_add_struct(b,
SPA_POD_Bool(active));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void client_node_marshal_event_method(void *object, struct spa_event *event)
static int client_node_marshal_event_method(void *object, struct spa_event *event)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -159,7 +143,7 @@ static void client_node_marshal_event_method(void *object, struct spa_event *eve
spa_pod_builder_add_struct(b,
SPA_POD_Pod(event));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int client_node_demarshal_add_mem(void *object, void *data, size_t size)
@ -215,18 +199,17 @@ static int client_node_demarshal_set_param(void *object, void *data, size_t size
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq, id, flags;
uint32_t id, flags;
const struct spa_pod *param = NULL;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Id(&id),
SPA_POD_Int(&flags),
SPA_POD_PodObject(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, 0, seq, id, flags, param);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, 0, id, flags, param);
return 0;
}
@ -250,15 +233,13 @@ static int client_node_demarshal_command(void *object, void *data, size_t size)
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
const struct spa_command *command;
uint32_t seq;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_PodObject(&command)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, 0, seq, command);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, 0, command);
return 0;
}
@ -266,16 +247,15 @@ static int client_node_demarshal_add_port(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
int32_t seq, direction, port_id;
int32_t direction, port_id;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, 0, seq, direction, port_id);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, 0, direction, port_id);
return 0;
}
@ -283,16 +263,15 @@ static int client_node_demarshal_remove_port(void *object, void *data, size_t si
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
int32_t seq, direction, port_id;
int32_t direction, port_id;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, 0, seq, direction, port_id);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, 0, direction, port_id);
return 0;
}
@ -300,12 +279,11 @@ static int client_node_demarshal_port_set_param(void *object, void *data, size_t
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq, direction, port_id, id, flags;
uint32_t direction, port_id, id, flags;
const struct spa_pod *param = NULL;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Id(&id),
@ -314,7 +292,7 @@ static int client_node_demarshal_port_set_param(void *object, void *data, size_t
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param, 0,
seq, direction, port_id, id, flags, param);
direction, port_id, id, flags, param);
return 0;
}
@ -323,14 +301,13 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
struct spa_pod_frame f;
uint32_t seq, direction, port_id, mix_id, n_buffers, data_id;
uint32_t direction, port_id, mix_id, n_buffers, data_id;
struct pw_client_node_buffer *buffers;
uint32_t i, j;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_push_struct(&prs, &f) < 0 ||
spa_pod_parser_get(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Int(&mix_id),
@ -376,7 +353,7 @@ static int client_node_demarshal_port_use_buffers(void *object, void *data, size
d->data = SPA_UINT32_TO_PTR(data_id);
}
}
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, 0, seq,
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, 0,
direction,
port_id,
mix_id,
@ -388,11 +365,10 @@ static int client_node_demarshal_port_set_io(void *object, void *data, size_t si
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq, direction, port_id, mix_id, id, memid, off, sz;
uint32_t direction, port_id, mix_id, id, memid, off, sz;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&direction),
SPA_POD_Int(&port_id),
SPA_POD_Int(&mix_id),
@ -403,7 +379,6 @@ static int client_node_demarshal_port_set_io(void *object, void *data, size_t si
return -EINVAL;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io, 0,
seq,
direction, port_id, mix_id,
id, memid,
off, sz);
@ -457,7 +432,7 @@ static int client_node_demarshal_set_io(void *object, void *data, size_t size)
return 0;
}
static void
static int
client_node_marshal_add_mem(void *object,
uint32_t mem_id,
uint32_t type,
@ -474,10 +449,10 @@ client_node_marshal_add_mem(void *object,
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, memfd)),
SPA_POD_Int(flags));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd)
static int client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -489,11 +464,11 @@ static void client_node_marshal_transport(void *object, uint32_t node_id, int re
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, readfd)),
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, writefd)));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t flags,
static int
client_node_marshal_set_param(void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
@ -502,15 +477,14 @@ client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void client_node_marshal_event_event(void *object, const struct spa_event *event)
static int client_node_marshal_event_event(void *object, const struct spa_event *event)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -520,11 +494,11 @@ static void client_node_marshal_event_event(void *object, const struct spa_event
spa_pod_builder_add_struct(b,
SPA_POD_Pod(event));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
static int
client_node_marshal_command(void *object, const struct spa_command *command)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -532,15 +506,14 @@ client_node_marshal_command(void *object, uint32_t seq, const struct spa_command
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Pod(command));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_add_port(void *object,
uint32_t seq, enum spa_direction direction, uint32_t port_id)
enum spa_direction direction, uint32_t port_id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -548,16 +521,15 @@ client_node_marshal_add_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_remove_port(void *object,
uint32_t seq, enum spa_direction direction, uint32_t port_id)
enum spa_direction direction, uint32_t port_id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -565,16 +537,14 @@ client_node_marshal_remove_port(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_port_set_param(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
@ -587,19 +557,17 @@ client_node_marshal_port_set_param(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_port_use_buffers(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t mix_id,
@ -614,7 +582,6 @@ client_node_marshal_port_use_buffers(void *object,
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Int(mix_id),
@ -649,12 +616,11 @@ client_node_marshal_port_use_buffers(void *object,
}
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_port_set_io(void *object,
uint32_t seq,
uint32_t direction,
uint32_t port_id,
uint32_t mix_id,
@ -669,7 +635,6 @@ client_node_marshal_port_set_io(void *object,
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO);
spa_pod_builder_add_struct(b,
SPA_POD_Int(seq),
SPA_POD_Int(direction),
SPA_POD_Int(port_id),
SPA_POD_Int(mix_id),
@ -678,10 +643,10 @@ client_node_marshal_port_set_io(void *object,
SPA_POD_Int(offset),
SPA_POD_Int(size));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_set_activation(void *object,
uint32_t node_id,
int signalfd,
@ -701,10 +666,10 @@ client_node_marshal_set_activation(void *object,
SPA_POD_Int(offset),
SPA_POD_Int(size));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void
static int
client_node_marshal_set_io(void *object,
uint32_t id,
uint32_t memid,
@ -720,23 +685,7 @@ client_node_marshal_set_io(void *object,
SPA_POD_Int(memid),
SPA_POD_Int(offset),
SPA_POD_Int(size));
pw_protocol_native_end_resource(resource, b);
}
static int client_node_demarshal_done(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t seq, res;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&seq),
SPA_POD_Int(&res)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, 0, seq, res);
return 0;
return pw_protocol_native_end_resource(resource, b);
}
static int client_node_demarshal_update(void *object, void *data, size_t size)
@ -882,7 +831,6 @@ static int client_node_demarshal_event_method(void *object, void *data, size_t s
static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_method_marshal = {
PW_VERSION_CLIENT_NODE_PROXY_METHODS,
&client_node_marshal_done,
&client_node_marshal_update,
&client_node_marshal_port_update,
&client_node_marshal_set_active,
@ -890,7 +838,6 @@ static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_
};
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_method_demarshal[] = {
{ &client_node_demarshal_done, 0 },
{ &client_node_demarshal_update, 0 },
{ &client_node_demarshal_port_update, 0 },
{ &client_node_demarshal_set_active, 0 },

View file

@ -343,9 +343,9 @@ static struct mix *ensure_mix(struct node_data *data,
return mix;
}
static void client_node_add_mem(void *object,
uint32_t mem_id,
uint32_t type, int memfd, uint32_t flags)
static int client_node_add_mem(void *object,
uint32_t mem_id,
uint32_t type, int memfd, uint32_t flags)
{
struct pw_proxy *proxy = object;
struct node_data *data = proxy->user_data;
@ -355,7 +355,7 @@ static void client_node_add_mem(void *object,
if (m) {
pw_log_warn("duplicate mem %u, fd %d, flags %d",
mem_id, memfd, flags);
return;
return -EINVAL;
}
m = pw_array_add(&data->mems, sizeof(struct mem));
@ -367,10 +367,11 @@ static void client_node_add_mem(void *object,
m->ref = 0;
m->map.map = PW_MAP_RANGE_INIT;
m->map.ptr = NULL;
return 0;
}
static void client_node_transport(void *object, uint32_t node_id,
int readfd, int writefd)
static int client_node_transport(void *object, uint32_t node_id,
int readfd, int writefd)
{
struct pw_proxy *proxy = object;
struct node_data *data = proxy->user_data;
@ -392,14 +393,16 @@ static void client_node_transport(void *object, uint32_t node_id,
pw_client_node_proxy_set_active(data->node_proxy, true);
pw_remote_events_exported(remote, proxy->id, node_id);
return 0;
}
static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32_t change_mask)
static int add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32_t change_mask)
{
struct node_data *data = proxy->user_data;
struct spa_port_info pi = SPA_PORT_INFO_INIT();
uint32_t n_params = 0;
struct spa_pod **params = NULL;
int res;
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_PARAMS) {
uint32_t idx1, idx2, id;
@ -446,7 +449,7 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32
pi.flags &= ~SPA_PORT_FLAG_CAN_ALLOC_BUFFERS;
}
pw_client_node_proxy_port_update(data->node_proxy,
res = pw_client_node_proxy_port_update(data->node_proxy,
port->direction,
port->port_id,
change_mask,
@ -458,17 +461,19 @@ static void add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32
free(params[--n_params]);
free(params);
}
return res;
}
static void
client_node_set_param(void *object, uint32_t seq, uint32_t id, uint32_t flags,
static int
client_node_set_param(void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
pw_log_warn("set param not implemented");
return -ENOTSUP;
}
static void
static int
client_node_set_io(void *object,
uint32_t id,
uint32_t memid,
@ -488,12 +493,12 @@ client_node_set_io(void *object,
m = find_mem(data, memid);
if (m == NULL) {
pw_log_warn("unknown memory id %u", memid);
return;
return -EINVAL;
}
ptr = mem_map(data, &m->map, m->fd,
PROT_READ|PROT_WRITE, offset, size);
if (ptr == NULL)
return;
return -errno;
m->ref++;
}
@ -508,12 +513,13 @@ client_node_set_io(void *object,
}
data->position = ptr;
}
spa_node_set_io(data->node->node, id, ptr, size);
return spa_node_set_io(data->node->node, id, ptr, size);
}
static void client_node_event(void *object, const struct spa_event *event)
static int client_node_event(void *object, const struct spa_event *event)
{
pw_log_warn("unhandled node event %d", SPA_EVENT_TYPE(event));
return -ENOTSUP;
}
static int
@ -527,7 +533,7 @@ do_pause_source(struct spa_loop *loop,
return 0;
}
static void client_node_command(void *object, uint32_t seq, const struct spa_command *command)
static int client_node_command(void *object, const struct spa_command *command)
{
struct pw_proxy *proxy = object;
struct node_data *data = proxy->user_data;
@ -536,50 +542,58 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Pause:
pw_log_debug("node %p: pause %d", proxy, seq);
pw_log_debug("node %p: pause", proxy);
if (data->rtsocket_source) {
pw_loop_invoke(data->core->data_loop,
do_pause_source, 1, NULL, 0, true, data);
}
if ((res = pw_node_set_state(data->node, PW_NODE_STATE_IDLE)) < 0)
if ((res = pw_node_set_state(data->node, PW_NODE_STATE_IDLE)) < 0) {
pw_log_warn("node %p: pause failed", proxy);
pw_proxy_error(proxy, res, "pause failed");
}
pw_client_node_proxy_done(data->node_proxy, seq, res);
break;
case SPA_NODE_COMMAND_Start:
pw_log_debug("node %p: start %d", proxy, seq);
pw_log_debug("node %p: start", proxy);
if ((res = pw_node_set_state(data->node, PW_NODE_STATE_RUNNING)) < 0) {
pw_log_warn("node %p: start failed", proxy);
pw_proxy_error(proxy, res, "start failed");
}
else if (data->rtsocket_source) {
pw_loop_update_io(remote->core->data_loop,
data->rtsocket_source,
SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP);
}
pw_client_node_proxy_done(data->node_proxy, seq, res);
break;
default:
pw_log_warn("unhandled node command %d", SPA_NODE_COMMAND_ID(command));
pw_client_node_proxy_done(data->node_proxy, seq, -ENOTSUP);
res = -ENOTSUP;
pw_proxy_error(proxy, res, "command %d not supported", SPA_NODE_COMMAND_ID(command));
}
return res;
}
static void
client_node_add_port(void *object, uint32_t seq, enum spa_direction direction, uint32_t port_id)
static int
client_node_add_port(void *object, enum spa_direction direction, uint32_t port_id)
{
struct pw_proxy *proxy = object;
pw_log_warn("add port not supported");
pw_proxy_error(proxy, -ENOTSUP, "add port not supported");
return -ENOTSUP;
}
static void
client_node_remove_port(void *object, uint32_t seq, enum spa_direction direction, uint32_t port_id)
static int
client_node_remove_port(void *object, enum spa_direction direction, uint32_t port_id)
{
struct pw_proxy *proxy = object;
pw_log_warn("remove port not supported");
pw_proxy_error(proxy, -ENOTSUP, "remove port not supported");
return -ENOTSUP;
}
static void clear_buffers(struct node_data *data, struct mix *mix)
static int clear_buffers(struct node_data *data, struct mix *mix)
{
struct pw_port *port = mix->port;
struct buffer *b;
@ -589,7 +603,7 @@ static void clear_buffers(struct node_data *data, struct mix *mix)
pw_log_debug("port %p: clear buffers %d", port, mix->mix_id);
if ((res = pw_port_use_buffers(port, mix->mix_id, NULL, 0)) < 0) {
pw_log_error("port %p: error clear buffers %s", port, spa_strerror(res));
return;
return res;
}
pw_array_for_each(b, &mix->buffers) {
@ -608,11 +622,11 @@ static void clear_buffers(struct node_data *data, struct mix *mix)
free(b->buf);
}
mix->buffers.size = 0;
return 0;
}
static void
static int
client_node_port_set_param(void *object,
uint32_t seq,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
@ -625,6 +639,7 @@ client_node_port_set_param(void *object,
port = pw_node_find_port(data->node, direction, port_id);
if (port == NULL) {
res = -EINVAL;
pw_proxy_error(proxy, res, "unknown port");
goto done;
}
@ -639,20 +654,22 @@ client_node_port_set_param(void *object,
}
res = pw_port_set_param(port, SPA_ID_INVALID, id, flags, param);
if (res < 0)
if (res < 0) {
pw_proxy_error(proxy, res, "can't set port param: %s", spa_strerror(res));
goto done;
}
add_port_update(proxy, port,
if ((res = add_port_update(proxy, port,
PW_CLIENT_NODE_PORT_UPDATE_PARAMS |
PW_CLIENT_NODE_PORT_UPDATE_INFO);
PW_CLIENT_NODE_PORT_UPDATE_INFO)) < 0)
pw_proxy_error(proxy, res, "can't add port update");
done:
pw_client_node_proxy_done(data->node_proxy, seq, res);
return res;
}
static void
static int
client_node_port_use_buffers(void *object,
uint32_t seq,
enum spa_direction direction, uint32_t port_id, uint32_t mix_id,
uint32_t n_buffers, struct pw_client_node_buffer *buffers)
{
@ -667,6 +684,7 @@ client_node_port_use_buffers(void *object,
mix = ensure_mix(data, direction, port_id, mix_id);
if (mix == NULL) {
res = -EINVAL;
pw_proxy_error(proxy, res, "can add mix");
goto done;
}
@ -687,6 +705,7 @@ client_node_port_use_buffers(void *object,
if (m == NULL) {
pw_log_error("unknown memory id %u", buffers[i].mem_id);
res = -EINVAL;
pw_proxy_error(proxy, res, "unknown memory %u", buffers[i].mem_id);
goto cleanup;
}
@ -698,6 +717,7 @@ client_node_port_use_buffers(void *object,
buffers[i].offset, buffers[i].size);
if (bmem.map.ptr == NULL) {
res = -errno;
pw_proxy_error(proxy, res, "can't mmap memory: %s", spa_strerror(res));
goto cleanup;
}
if (mlock(bmem.map.ptr, bmem.map.map.size) < 0)
@ -716,6 +736,7 @@ client_node_port_use_buffers(void *object,
b = bid->buf = malloc(size);
if (b == NULL) {
res = -ENOMEM;
pw_proxy_error(proxy, res, "can't alloc memory: %s", spa_strerror(res));
goto cleanup;
}
memcpy(b, buffers[i].buffer, sizeof(struct spa_buffer));
@ -757,6 +778,7 @@ client_node_port_use_buffers(void *object,
if (bm == NULL) {
pw_log_error("unknown buffer mem %u", mem_id);
res = -EINVAL;
pw_proxy_error(proxy, res, "unknown buffer mem %u", mem_id);
goto cleanup;
}
@ -783,11 +805,11 @@ client_node_port_use_buffers(void *object,
bufs[i] = b;
}
res = pw_port_use_buffers(mix->port, mix->mix_id, bufs, n_buffers);
if ((res = pw_port_use_buffers(mix->port, mix->mix_id, bufs, n_buffers)) < 0)
pw_proxy_error(proxy, res, "can't use buffers: %s", spa_strerror(res));
done:
pw_client_node_proxy_done(data->node_proxy, seq, res);
return;
return res;
cleanup:
clear_buffers(data, mix);
@ -795,9 +817,8 @@ client_node_port_use_buffers(void *object,
}
static void
static int
client_node_port_set_io(void *object,
uint32_t seq,
uint32_t direction,
uint32_t port_id,
uint32_t mix_id,
@ -811,10 +832,14 @@ client_node_port_set_io(void *object,
struct mix *mix;
struct mem *m;
void *ptr;
int res = 0;
mix = ensure_mix(data, direction, port_id, mix_id);
if (mix == NULL)
return;
if (mix == NULL) {
res = -EINVAL;
pw_proxy_error(proxy, res, "can't get mixer: %s", spa_strerror(res));
return res;
}
if (memid == SPA_ID_INVALID) {
ptr = NULL;
@ -824,12 +849,17 @@ client_node_port_set_io(void *object,
m = find_mem(data, memid);
if (m == NULL) {
pw_log_warn("unknown memory id %u", memid);
return;
res = -EINVAL;
pw_proxy_error(proxy, res, "unknown memory id %u", memid);
return res;
}
ptr = mem_map(data, &m->map, m->fd,
PROT_READ|PROT_WRITE, offset, size);
if (ptr == NULL)
return;
if (ptr == NULL) {
res = -errno;
pw_proxy_error(proxy, res, "mmap failed: %s", spa_strerror(res));
return res;
}
m->ref++;
}
@ -848,12 +878,14 @@ client_node_port_set_io(void *object,
if (ptr)
activate_mix(data, mix);
} else {
spa_node_port_set_io(mix->port->node->node,
if ((res = spa_node_port_set_io(mix->port->node->node,
direction, port_id,
id,
ptr,
size);
size)) < 0)
pw_proxy_error(proxy, res, "set_io failed: %s", spa_strerror(res));
}
return res;
}
#if 0
@ -868,7 +900,7 @@ static int link_signal_func(void *user_data)
}
#endif
static void
static int
client_node_set_activation(void *object,
uint32_t node_id,
int signalfd,
@ -881,6 +913,7 @@ client_node_set_activation(void *object,
struct pw_node *node = data->node;
struct mem *m;
struct pw_node_activation *ptr;
int res = 0;
if (memid == SPA_ID_INVALID) {
ptr = NULL;
@ -890,12 +923,17 @@ client_node_set_activation(void *object,
m = find_mem(data, memid);
if (m == NULL) {
pw_log_warn("unknown memory id %u", memid);
return;
res = -EINVAL;
pw_proxy_error(proxy, res, "unknown memory id %u", memid);
return res;
}
ptr = mem_map(data, &m->map, m->fd,
PROT_READ|PROT_WRITE, offset, size);
if (ptr == NULL)
return;
if (ptr == NULL) {
res = -errno;
pw_proxy_error(proxy, res, "mmap failed: %s", spa_strerror(res));
return res;
}
m->ref++;
}
pw_log_debug("node %p: set activation %d", node, node_id);
@ -914,6 +952,7 @@ client_node_set_activation(void *object,
link->link.state->pending);
}
#endif
return res;
}
static const struct pw_client_node_proxy_events client_node_events = {
@ -956,7 +995,6 @@ static void do_node_init(struct pw_proxy *proxy)
PW_CLIENT_NODE_PORT_UPDATE_PARAMS |
PW_CLIENT_NODE_PORT_UPDATE_INFO);
}
pw_client_node_proxy_done(data->node_proxy, 0, 0);
}
static void clear_mix(struct node_data *data, struct mix *mix)

View file

@ -476,8 +476,7 @@ on_remote_data(void *data, int fd, enum spa_io mask)
if (mask & SPA_IO_IN) {
uint8_t opcode;
uint32_t id;
uint32_t size;
uint32_t id, size;
void *message;
while (!impl->disconnecting
@ -773,11 +772,11 @@ static int impl_ext_get_proxy_fd(struct pw_proxy *proxy, uint32_t index)
return pw_protocol_native_connection_get_fd(impl->connection, index);
}
static void impl_ext_end_proxy(struct pw_proxy *proxy,
static int impl_ext_end_proxy(struct pw_proxy *proxy,
struct spa_pod_builder *builder)
{
struct client *impl = SPA_CONTAINER_OF(proxy->remote->conn, struct client, this);
pw_protocol_native_connection_end(impl->connection, builder);
return pw_protocol_native_connection_end(impl->connection, builder);
}
static struct spa_pod_builder *
@ -798,11 +797,11 @@ static int impl_ext_get_resource_fd(struct pw_resource *resource, uint32_t index
return pw_protocol_native_connection_get_fd(data->connection, index);
}
static void impl_ext_end_resource(struct pw_resource *resource,
static int impl_ext_end_resource(struct pw_resource *resource,
struct spa_pod_builder *builder)
{
struct client_data *data = resource->client->user_data;
pw_protocol_native_connection_end(data->connection, builder);
return pw_protocol_native_connection_end(data->connection, builder);
}
const static struct pw_protocol_native_ext protocol_ext_impl = {

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

View file

@ -90,7 +90,7 @@ struct spa_pod_builder *
pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection *conn,
struct pw_proxy *proxy,
uint8_t opcode);
void
int
pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
struct spa_pod_builder *builder);

View file

@ -32,7 +32,7 @@
#include "connection.h"
static void core_marshal_hello(void *object, uint32_t version)
static int core_method_marshal_hello(void *object, uint32_t version)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -42,10 +42,10 @@ static void core_marshal_hello(void *object, uint32_t version)
spa_pod_builder_add_struct(b,
SPA_POD_Int(version));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void core_marshal_sync(void *object, uint32_t seq)
static int core_method_marshal_sync(void *object, uint32_t id, uint32_t seq)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -53,12 +53,42 @@ static void core_marshal_sync(void *object, uint32_t seq)
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_SYNC);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Int(seq));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void core_marshal_get_registry(void *object, uint32_t version, uint32_t new_id)
static int core_method_marshal_done(void *object, uint32_t id, uint32_t seq)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_DONE);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Int(seq));
return pw_protocol_native_end_proxy(proxy, b);
}
static int core_method_marshal_error(void *object, uint32_t id, int res, const char *error)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_ERROR);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Int(res),
SPA_POD_String(error));
return pw_protocol_native_end_proxy(proxy, b);
}
static int core_method_marshal_get_registry(void *object, uint32_t version, uint32_t new_id)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -69,7 +99,7 @@ static void core_marshal_get_registry(void *object, uint32_t version, uint32_t n
SPA_POD_Int(version),
SPA_POD_Int(new_id));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void push_dict(struct spa_pod_builder *b, const struct spa_dict *dict)
@ -88,8 +118,8 @@ static void push_dict(struct spa_pod_builder *b, const struct spa_dict *dict)
spa_pod_builder_pop(b, &f);
}
static void
core_marshal_create_object(void *object,
static int
core_method_marshal_create_object(void *object,
const char *factory_name,
uint32_t type, uint32_t version,
const struct spa_dict *props, uint32_t new_id)
@ -110,11 +140,11 @@ core_marshal_create_object(void *object,
spa_pod_builder_int(b, new_id);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void
core_marshal_destroy(void *object, uint32_t id)
static int
core_method_marshal_destroy(void *object, uint32_t id)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -124,10 +154,10 @@ core_marshal_destroy(void *object, uint32_t id)
spa_pod_builder_add_struct(b,
SPA_POD_Int(id));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int core_demarshal_info(void *object, void *data, size_t size)
static int core_event_demarshal_info(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_dict props;
@ -164,26 +194,40 @@ static int core_demarshal_info(void *object, void *data, size_t size)
NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_core_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_core_proxy_events, info, 0, &info);
}
static int core_demarshal_done(void *object, void *data, size_t size)
static int core_event_demarshal_done(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq;
uint32_t id, seq;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&seq)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_core_proxy_events, done, 0, seq);
return 0;
return pw_proxy_notify(proxy, struct pw_core_proxy_events, done, 0, id, seq);
}
static int core_demarshal_error(void *object, void *data, size_t size)
static int core_event_demarshal_sync(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t id, seq;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&seq)) < 0)
return -EINVAL;
return pw_proxy_notify(proxy, struct pw_core_proxy_events, sync, 0, id, seq);
}
static int core_event_demarshal_error(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
@ -197,11 +241,10 @@ static int core_demarshal_error(void *object, void *data, size_t size)
SPA_POD_String(&error)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_core_proxy_events, error, 0, id, res, error);
return 0;
return pw_proxy_notify(proxy, struct pw_core_proxy_events, error, 0, id, res, error);
}
static int core_demarshal_remove_id(void *object, void *data, size_t size)
static int core_event_demarshal_remove_id(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
@ -211,11 +254,10 @@ static int core_demarshal_remove_id(void *object, void *data, size_t size)
if (spa_pod_parser_get_struct(&prs, SPA_POD_Int(&id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, 0, id);
return 0;
return pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, 0, id);
}
static void core_marshal_info(void *object, const struct pw_core_info *info)
static int core_event_marshal_info(void *object, const struct pw_core_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -236,10 +278,10 @@ static void core_marshal_info(void *object, const struct pw_core_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_done(void *object, uint32_t seq)
static int core_event_marshal_done(void *object, uint32_t id, uint32_t seq)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -247,12 +289,27 @@ static void core_marshal_done(void *object, uint32_t seq)
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_DONE);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Int(seq));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_error(void *object, uint32_t id, int res, const char *error)
static int core_event_marshal_sync(void *object, uint32_t id, uint32_t seq)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_SYNC);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Int(seq));
return pw_protocol_native_end_resource(resource, b);
}
static int core_event_marshal_error(void *object, uint32_t id, int res, const char *error)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -264,10 +321,10 @@ static void core_marshal_error(void *object, uint32_t id, int res, const char *e
SPA_POD_Int(res),
SPA_POD_String(error));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_remove_id(void *object, uint32_t id)
static int core_event_marshal_remove_id(void *object, uint32_t id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -277,10 +334,10 @@ static void core_marshal_remove_id(void *object, uint32_t id)
spa_pod_builder_add_struct(b,
SPA_POD_Int(id));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int core_demarshal_hello(void *object, void *data, size_t size)
static int core_method_demarshal_hello(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
@ -291,26 +348,57 @@ static int core_demarshal_hello(void *object, void *data, size_t size)
SPA_POD_Int(&version)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_core_proxy_methods, hello, 0, version);
return 0;
return pw_resource_do(resource, struct pw_core_proxy_methods, hello, 0, version);
}
static int core_demarshal_sync(void *object, void *data, size_t size)
static int core_method_demarshal_sync(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t seq;
uint32_t id, seq;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&seq)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_core_proxy_methods, sync, 0, seq);
return 0;
return pw_resource_do(resource, struct pw_core_proxy_methods, sync, 0, id, seq);
}
static int core_demarshal_get_registry(void *object, void *data, size_t size)
static int core_method_demarshal_done(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t id, seq;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&seq)) < 0)
return -EINVAL;
return pw_resource_do(resource, struct pw_core_proxy_methods, done, 0, id, seq);
}
static int core_method_demarshal_error(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t id, res;
const char *error;
spa_pod_parser_init(&prs, data, size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&res),
SPA_POD_String(&error)) < 0)
return -EINVAL;
return pw_resource_do(resource, struct pw_core_proxy_methods, error, 0, id, res, error);
}
static int core_method_demarshal_get_registry(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
@ -322,11 +410,10 @@ static int core_demarshal_get_registry(void *object, void *data, size_t size)
SPA_POD_Int(&new_id)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, 0, version, new_id);
return 0;
return pw_resource_do(resource, struct pw_core_proxy_methods, get_registry, 0, version, new_id);
}
static int core_demarshal_create_object(void *object, void *data, size_t size)
static int core_method_demarshal_create_object(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
@ -362,13 +449,12 @@ static int core_demarshal_create_object(void *object, void *data, size_t size)
SPA_POD_Int(&new_id), NULL) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_core_proxy_methods, create_object, 0, factory_name,
return pw_resource_do(resource, struct pw_core_proxy_methods, create_object, 0, factory_name,
type, version,
&props, new_id);
return 0;
}
static int core_demarshal_destroy(void *object, void *data, size_t size)
static int core_method_demarshal_destroy(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
@ -379,11 +465,10 @@ static int core_demarshal_destroy(void *object, void *data, size_t size)
SPA_POD_Int(&id)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_core_proxy_methods, destroy, 0, id);
return 0;
return pw_resource_do(resource, struct pw_core_proxy_methods, destroy, 0, id);
}
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
static int registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
uint32_t type, uint32_t version, const struct spa_dict *props)
{
struct pw_resource *resource = object;
@ -403,10 +488,10 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_i
push_dict(b, props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static void registry_marshal_global_remove(void *object, uint32_t id)
static int registry_marshal_global_remove(void *object, uint32_t id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -415,7 +500,7 @@ static void registry_marshal_global_remove(void *object, uint32_t id)
spa_pod_builder_add_struct(b, SPA_POD_Int(id));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int registry_demarshal_bind(void *object, void *data, size_t size)
@ -432,8 +517,7 @@ static int registry_demarshal_bind(void *object, void *data, size_t size)
SPA_POD_Int(&new_id)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_registry_proxy_methods, bind, 0, id, type, version, new_id);
return 0;
return pw_resource_do(resource, struct pw_registry_proxy_methods, bind, 0, id, type, version, new_id);
}
static int registry_demarshal_destroy(void *object, void *data, size_t size)
@ -447,11 +531,10 @@ static int registry_demarshal_destroy(void *object, void *data, size_t size)
SPA_POD_Int(&id)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_registry_proxy_methods, destroy, 0, id);
return 0;
return pw_resource_do(resource, struct pw_registry_proxy_methods, destroy, 0, id);
}
static void module_marshal_info(void *object, const struct pw_module_info *info)
static int module_marshal_info(void *object, const struct pw_module_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -470,7 +553,7 @@ static void module_marshal_info(void *object, const struct pw_module_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int module_demarshal_info(void *object, void *data, size_t size)
@ -505,11 +588,10 @@ static int module_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_module_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_module_proxy_events, info, 0, &info);
}
static void device_marshal_info(void *object, const struct pw_device_info *info)
static int device_marshal_info(void *object, const struct pw_device_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -526,7 +608,7 @@ static void device_marshal_info(void *object, const struct pw_device_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int device_demarshal_info(void *object, void *data, size_t size)
@ -559,11 +641,10 @@ static int device_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_device_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_device_proxy_events, info, 0, &info);
}
static void device_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
static int device_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
@ -577,7 +658,7 @@ static void device_marshal_param(void *object, uint32_t id, uint32_t index, uint
SPA_POD_Int(next),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int device_demarshal_param(void *object, void *data, size_t size)
@ -595,11 +676,10 @@ static int device_demarshal_param(void *object, void *data, size_t size)
SPA_POD_Pod(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_device_proxy_events, param, 0, id, index, next, param);
return 0;
return pw_proxy_notify(proxy, struct pw_device_proxy_events, param, 0, id, index, next, param);
}
static void device_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
static int device_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
const struct spa_pod *filter)
{
struct pw_proxy *proxy = object;
@ -613,7 +693,7 @@ static void device_marshal_enum_params(void *object, uint32_t id, uint32_t index
SPA_POD_Int(num),
SPA_POD_Pod(filter));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int device_demarshal_enum_params(void *object, void *data, size_t size)
@ -631,11 +711,10 @@ static int device_demarshal_enum_params(void *object, void *data, size_t size)
SPA_POD_Pod(&filter)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_device_proxy_methods, enum_params, 0, id, index, num, filter);
return 0;
return pw_resource_do(resource, struct pw_device_proxy_methods, enum_params, 0, id, index, num, filter);
}
static void device_marshal_set_param(void *object, uint32_t id, uint32_t flags,
static int device_marshal_set_param(void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct pw_proxy *proxy = object;
@ -647,7 +726,7 @@ static void device_marshal_set_param(void *object, uint32_t id, uint32_t flags,
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int device_demarshal_set_param(void *object, void *data, size_t size)
@ -664,11 +743,10 @@ static int device_demarshal_set_param(void *object, void *data, size_t size)
SPA_POD_Pod(&param)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_device_proxy_methods, set_param, 0, id, flags, param);
return 0;
return pw_resource_do(resource, struct pw_device_proxy_methods, set_param, 0, id, flags, param);
}
static void factory_marshal_info(void *object, const struct pw_factory_info *info)
static int factory_marshal_info(void *object, const struct pw_factory_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -687,7 +765,7 @@ static void factory_marshal_info(void *object, const struct pw_factory_info *inf
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int factory_demarshal_info(void *object, void *data, size_t size)
@ -722,11 +800,10 @@ static int factory_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_factory_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_factory_proxy_events, info, 0, &info);
}
static void node_marshal_info(void *object, const struct pw_node_info *info)
static int node_marshal_info(void *object, const struct pw_node_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -749,7 +826,7 @@ static void node_marshal_info(void *object, const struct pw_node_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int node_demarshal_info(void *object, void *data, size_t size)
@ -788,11 +865,10 @@ static int node_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_node_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_node_proxy_events, info, 0, &info);
}
static void node_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
static int node_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
@ -806,7 +882,7 @@ static void node_marshal_param(void *object, uint32_t id, uint32_t index, uint32
SPA_POD_Int(next),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int node_demarshal_param(void *object, void *data, size_t size)
@ -824,11 +900,10 @@ static int node_demarshal_param(void *object, void *data, size_t size)
SPA_POD_Pod(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_node_proxy_events, param, 0, id, index, next, param);
return 0;
return pw_proxy_notify(proxy, struct pw_node_proxy_events, param, 0, id, index, next, param);
}
static void node_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
static int node_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
const struct spa_pod *filter)
{
struct pw_proxy *proxy = object;
@ -842,7 +917,7 @@ static void node_marshal_enum_params(void *object, uint32_t id, uint32_t index,
SPA_POD_Int(num),
SPA_POD_Pod(filter));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int node_demarshal_enum_params(void *object, void *data, size_t size)
@ -860,11 +935,10 @@ static int node_demarshal_enum_params(void *object, void *data, size_t size)
SPA_POD_Pod(&filter)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_node_proxy_methods, enum_params, 0, id, index, num, filter);
return 0;
return pw_resource_do(resource, struct pw_node_proxy_methods, enum_params, 0, id, index, num, filter);
}
static void node_marshal_set_param(void *object, uint32_t id, uint32_t flags,
static int node_marshal_set_param(void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct pw_proxy *proxy = object;
@ -876,7 +950,7 @@ static void node_marshal_set_param(void *object, uint32_t id, uint32_t flags,
SPA_POD_Id(id),
SPA_POD_Int(flags),
SPA_POD_Pod(param));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int node_demarshal_set_param(void *object, void *data, size_t size)
@ -893,11 +967,10 @@ static int node_demarshal_set_param(void *object, void *data, size_t size)
SPA_POD_Pod(&param)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_node_proxy_methods, set_param, 0, id, flags, param);
return 0;
return pw_resource_do(resource, struct pw_node_proxy_methods, set_param, 0, id, flags, param);
}
static void node_marshal_send_command(void *object, const struct spa_command *command)
static int node_marshal_send_command(void *object, const struct spa_command *command)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -905,7 +978,7 @@ static void node_marshal_send_command(void *object, const struct spa_command *co
b = pw_protocol_native_begin_proxy(proxy, PW_NODE_PROXY_METHOD_SEND_COMMAND);
spa_pod_builder_add_struct(b,
SPA_POD_Pod(command));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int node_demarshal_send_command(void *object, void *data, size_t size)
@ -919,11 +992,10 @@ static int node_demarshal_send_command(void *object, void *data, size_t size)
SPA_POD_Pod(&command)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_node_proxy_methods, send_command, 0, command);
return 0;
return pw_resource_do(resource, struct pw_node_proxy_methods, send_command, 0, command);
}
static void port_marshal_info(void *object, const struct pw_port_info *info)
static int port_marshal_info(void *object, const struct pw_port_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -940,7 +1012,7 @@ static void port_marshal_info(void *object, const struct pw_port_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int port_demarshal_info(void *object, void *data, size_t size)
@ -973,11 +1045,10 @@ static int port_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_port_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_port_proxy_events, info, 0, &info);
}
static void port_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
static int port_marshal_param(void *object, uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
@ -991,7 +1062,7 @@ static void port_marshal_param(void *object, uint32_t id, uint32_t index, uint32
SPA_POD_Int(next),
SPA_POD_Pod(param));
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int port_demarshal_param(void *object, void *data, size_t size)
@ -1009,11 +1080,10 @@ static int port_demarshal_param(void *object, void *data, size_t size)
SPA_POD_Pod(&param)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_port_proxy_events, param, 0, id, index, next, param);
return 0;
return pw_proxy_notify(proxy, struct pw_port_proxy_events, param, 0, id, index, next, param);
}
static void port_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
static int port_marshal_enum_params(void *object, uint32_t id, uint32_t index, uint32_t num,
const struct spa_pod *filter)
{
struct pw_proxy *proxy = object;
@ -1027,7 +1097,7 @@ static void port_marshal_enum_params(void *object, uint32_t id, uint32_t index,
SPA_POD_Int(num),
SPA_POD_Pod(filter));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int port_demarshal_enum_params(void *object, void *data, size_t size)
@ -1045,11 +1115,10 @@ static int port_demarshal_enum_params(void *object, void *data, size_t size)
SPA_POD_Pod(&filter)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_port_proxy_methods, enum_params, 0, id, index, num, filter);
return 0;
return pw_resource_do(resource, struct pw_port_proxy_methods, enum_params, 0, id, index, num, filter);
}
static void client_marshal_info(void *object, const struct pw_client_info *info)
static int client_marshal_info(void *object, const struct pw_client_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -1065,7 +1134,7 @@ static void client_marshal_info(void *object, const struct pw_client_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int client_demarshal_info(void *object, void *data, size_t size)
@ -1097,11 +1166,10 @@ static int client_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_client_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_client_proxy_events, info, 0, &info);
}
static void client_marshal_permissions(void *object, uint32_t index, uint32_t n_permissions,
static int client_marshal_permissions(void *object, uint32_t index, uint32_t n_permissions,
const struct pw_permission *permissions)
{
struct pw_resource *resource = object;
@ -1130,7 +1198,7 @@ static void client_marshal_permissions(void *object, uint32_t index, uint32_t n_
spa_pod_builder_pop(b, &f[1]);
spa_pod_builder_pop(b, &f[0]);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int client_demarshal_permissions(void *object, void *data, size_t size)
@ -1159,11 +1227,10 @@ static int client_demarshal_permissions(void *object, void *data, size_t size)
SPA_POD_Int(&permissions[i].permissions), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_client_proxy_events, permissions, 0, index, n_permissions, permissions);
return 0;
return pw_proxy_notify(proxy, struct pw_client_proxy_events, permissions, 0, index, n_permissions, permissions);
}
static void client_marshal_error(void *object, uint32_t id, int res, const char *error)
static int client_marshal_error(void *object, uint32_t id, int res, const char *error)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -1173,7 +1240,7 @@ static void client_marshal_error(void *object, uint32_t id, int res, const char
SPA_POD_Int(id),
SPA_POD_Int(res),
SPA_POD_String(error));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int client_demarshal_error(void *object, void *data, size_t size)
@ -1190,11 +1257,10 @@ static int client_demarshal_error(void *object, void *data, size_t size)
SPA_POD_String(&error)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_proxy_methods, error, 0, id, res, error);
return 0;
return pw_resource_do(resource, struct pw_client_proxy_methods, error, 0, id, res, error);
}
static void client_marshal_get_permissions(void *object, uint32_t index, uint32_t num)
static int client_marshal_get_permissions(void *object, uint32_t index, uint32_t num)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -1205,10 +1271,10 @@ static void client_marshal_get_permissions(void *object, uint32_t index, uint32_
SPA_POD_Int(index),
SPA_POD_Int(num));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void client_marshal_update_properties(void *object, const struct spa_dict *props)
static int client_marshal_update_properties(void *object, const struct spa_dict *props)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -1220,7 +1286,7 @@ static void client_marshal_update_properties(void *object, const struct spa_dict
push_dict(b, props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int client_demarshal_update_properties(void *object, void *data, size_t size)
@ -1245,9 +1311,8 @@ static int client_demarshal_update_properties(void *object, void *data, size_t s
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_resource_do(resource, struct pw_client_proxy_methods, update_properties, 0,
return pw_resource_do(resource, struct pw_client_proxy_methods, update_properties, 0,
&props);
return 0;
}
static int client_demarshal_get_permissions(void *object, void *data, size_t size)
@ -1262,11 +1327,10 @@ static int client_demarshal_get_permissions(void *object, void *data, size_t siz
SPA_POD_Int(&num)) < 0)
return -EINVAL;
pw_resource_do(resource, struct pw_client_proxy_methods, get_permissions, 0, index, num);
return 0;
return pw_resource_do(resource, struct pw_client_proxy_methods, get_permissions, 0, index, num);
}
static void client_marshal_update_permissions(void *object, uint32_t n_permissions,
static int client_marshal_update_permissions(void *object, uint32_t n_permissions,
const struct pw_permission *permissions)
{
struct pw_proxy *proxy = object;
@ -1284,7 +1348,7 @@ static void client_marshal_update_permissions(void *object, uint32_t n_permissio
}
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static int client_demarshal_update_permissions(void *object, void *data, size_t size)
@ -1308,12 +1372,11 @@ static int client_demarshal_update_permissions(void *object, void *data, size_t
SPA_POD_Int(&permissions[i].permissions), NULL) < 0)
return -EINVAL;
}
pw_resource_do(resource, struct pw_client_proxy_methods, update_permissions, 0,
return pw_resource_do(resource, struct pw_client_proxy_methods, update_permissions, 0,
n_permissions, permissions);
return 0;
}
static void link_marshal_info(void *object, const struct pw_link_info *info)
static int link_marshal_info(void *object, const struct pw_link_info *info)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -1336,7 +1399,7 @@ static void link_marshal_info(void *object, const struct pw_link_info *info)
push_dict(b, info->props);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
return pw_protocol_native_end_resource(resource, b);
}
static int link_demarshal_info(void *object, void *data, size_t size)
@ -1375,8 +1438,7 @@ static int link_demarshal_info(void *object, void *data, size_t size)
SPA_POD_String(&props.items[i].value), NULL) < 0)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_link_proxy_events, info, 0, &info);
return 0;
return pw_proxy_notify(proxy, struct pw_link_proxy_events, info, 0, &info);
}
static int registry_demarshal_global(void *object, void *data, size_t size)
@ -1410,10 +1472,9 @@ static int registry_demarshal_global(void *object, void *data, size_t size)
return -EINVAL;
}
pw_proxy_notify(proxy, struct pw_registry_proxy_events,
return pw_proxy_notify(proxy, struct pw_registry_proxy_events,
global, 0, id, parent_id, permissions, type, version,
props.n_items > 0 ? &props : NULL);
return 0;
}
static int registry_demarshal_global_remove(void *object, void *data, size_t size)
@ -1427,11 +1488,10 @@ static int registry_demarshal_global_remove(void *object, void *data, size_t siz
SPA_POD_Int(&id)) < 0)
return -EINVAL;
pw_proxy_notify(proxy, struct pw_registry_proxy_events, global_remove, 0, id);
return 0;
return pw_proxy_notify(proxy, struct pw_registry_proxy_events, global_remove, 0, id);
}
static void registry_marshal_bind(void *object, uint32_t id,
static int registry_marshal_bind(void *object, uint32_t id,
uint32_t type, uint32_t version, uint32_t new_id)
{
struct pw_proxy *proxy = object;
@ -1445,10 +1505,10 @@ static void registry_marshal_bind(void *object, uint32_t id,
SPA_POD_Int(version),
SPA_POD_Int(new_id));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static void registry_marshal_destroy(void *object, uint32_t id)
static int registry_marshal_destroy(void *object, uint32_t id)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -1456,39 +1516,45 @@ static void registry_marshal_destroy(void *object, uint32_t id)
b = pw_protocol_native_begin_proxy(proxy, PW_REGISTRY_PROXY_METHOD_DESTROY);
spa_pod_builder_add_struct(b,
SPA_POD_Int(id));
pw_protocol_native_end_proxy(proxy, b);
return pw_protocol_native_end_proxy(proxy, b);
}
static const struct pw_core_proxy_methods pw_protocol_native_core_method_marshal = {
PW_VERSION_CORE_PROXY_METHODS,
&core_marshal_hello,
&core_marshal_sync,
&core_marshal_get_registry,
&core_marshal_create_object,
&core_marshal_destroy,
&core_method_marshal_hello,
&core_method_marshal_sync,
&core_method_marshal_done,
&core_method_marshal_error,
&core_method_marshal_get_registry,
&core_method_marshal_create_object,
&core_method_marshal_destroy,
};
static const struct pw_protocol_native_demarshal pw_protocol_native_core_method_demarshal[PW_CORE_PROXY_METHOD_NUM] = {
{ &core_demarshal_hello, 0, },
{ &core_demarshal_sync, 0, },
{ &core_demarshal_get_registry, 0, },
{ &core_demarshal_create_object, 0, },
{ &core_demarshal_destroy, 0, }
{ &core_method_demarshal_hello, 0, },
{ &core_method_demarshal_sync, 0, },
{ &core_method_demarshal_done, 0, },
{ &core_method_demarshal_error, 0, },
{ &core_method_demarshal_get_registry, 0, },
{ &core_method_demarshal_create_object, 0, },
{ &core_method_demarshal_destroy, 0, }
};
static const struct pw_core_proxy_events pw_protocol_native_core_event_marshal = {
PW_VERSION_CORE_PROXY_EVENTS,
&core_marshal_done,
&core_marshal_error,
&core_marshal_remove_id,
&core_marshal_info
&core_event_marshal_info,
&core_event_marshal_done,
&core_event_marshal_sync,
&core_event_marshal_error,
&core_event_marshal_remove_id,
};
static const struct pw_protocol_native_demarshal pw_protocol_native_core_event_demarshal[PW_CORE_PROXY_EVENT_NUM] = {
{ &core_demarshal_done, 0, },
{ &core_demarshal_error, 0, },
{ &core_demarshal_remove_id, 0, },
{ &core_demarshal_info, 0, },
{ &core_event_demarshal_info, 0, },
{ &core_event_demarshal_done, 0, },
{ &core_event_demarshal_sync, 0, },
{ &core_event_demarshal_error, 0, },
{ &core_event_demarshal_remove_id, 0, },
};
static const struct pw_protocol_marshal pw_protocol_native_core_marshal = {

View file

@ -242,7 +242,7 @@ static void change_item(struct pw_spa_monitor *this, struct spa_pod *item, uint6
}
}
static void on_monitor_event(void *data, struct spa_event *event)
static int on_monitor_event(void *data, struct spa_event *event)
{
struct impl *impl = data;
struct pw_spa_monitor *this = &impl->this;
@ -265,6 +265,7 @@ static void on_monitor_event(void *data, struct spa_event *event)
change_item(this, item, now_nsec);
break;
}
return 0;
}
static void update_monitor(struct pw_core *core, const char *name)