mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
client-node: add more generic set_io method
Replace the set_position method with set_io that allows us to share other types of state with the client.
This commit is contained in:
parent
5a3eee9cac
commit
cc542935ea
5 changed files with 127 additions and 81 deletions
|
|
@ -64,6 +64,15 @@
|
|||
|
||||
#define CHECK_PORT_BUFFER(this,b,p) (b < p->n_buffers)
|
||||
|
||||
struct type {
|
||||
uint32_t client_node_position;
|
||||
};
|
||||
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->client_node_position = spa_type_map_get_id(map, PW_TYPE_CLIENT_NODE_IO__Position);
|
||||
}
|
||||
|
||||
struct mem {
|
||||
uint32_t id;
|
||||
int ref;
|
||||
|
|
@ -135,6 +144,8 @@ struct node {
|
|||
struct impl {
|
||||
struct pw_client_node this;
|
||||
|
||||
struct type type;
|
||||
|
||||
struct pw_core *core;
|
||||
struct pw_type *t;
|
||||
|
||||
|
|
@ -323,7 +334,6 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
{
|
||||
struct node *this;
|
||||
int res = 0;
|
||||
struct pw_type *t;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return -EINVAL;
|
||||
|
|
@ -333,8 +343,6 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
if (this->resource == NULL)
|
||||
return 0;
|
||||
|
||||
t = this->impl->t;
|
||||
|
||||
pw_client_node_resource_command(this->resource, this->seq, command);
|
||||
res = SPA_RESULT_RETURN_ASYNC(this->seq++);
|
||||
|
||||
|
|
@ -1202,10 +1210,11 @@ static void node_initialized(void *data)
|
|||
m = ensure_mem(impl, impl->io_areas->fd, t->data.MemFd, impl->io_areas->flags);
|
||||
pw_log_debug("client-node %p: io areas %p", node, impl->io_areas->ptr);
|
||||
|
||||
pw_client_node_resource_set_position(this->resource,
|
||||
m->id,
|
||||
area_size,
|
||||
sizeof(struct pw_client_node_position));
|
||||
pw_client_node_resource_set_io(this->resource,
|
||||
impl->type.client_node_position,
|
||||
m->id,
|
||||
area_size,
|
||||
sizeof(struct pw_client_node_position));
|
||||
|
||||
if ((global = pw_node_get_global(node)) != NULL)
|
||||
pw_client_node_registered(this, pw_global_get_id(global));
|
||||
|
|
@ -1358,8 +1367,9 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
impl->fds[0] = impl->fds[1] = -1;
|
||||
pw_log_debug("client-node %p: new", impl);
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
init_type(&impl->type, impl->t->map);
|
||||
|
||||
support = pw_core_get_support(impl->core, &n_support);
|
||||
node_init(&impl->node, NULL, support, n_support);
|
||||
impl->node.impl = impl;
|
||||
|
||||
|
|
|
|||
|
|
@ -440,22 +440,23 @@ static int client_node_demarshal_port_set_io(void *object, void *data, size_t si
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int client_node_demarshal_set_position(void *object, void *data, size_t size)
|
||||
static int client_node_demarshal_set_io(void *object, void *data, size_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
uint32_t memid, off, sz;
|
||||
uint32_t id, memid, off, sz;
|
||||
|
||||
spa_pod_parser_init(&prs, data, size, 0);
|
||||
if (spa_pod_parser_get(&prs,
|
||||
"["
|
||||
"I", &id,
|
||||
"i", &memid,
|
||||
"i", &off,
|
||||
"i", &sz, NULL) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_position,
|
||||
memid, off, sz);
|
||||
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_io,
|
||||
id, memid, off, sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -699,16 +700,18 @@ client_node_marshal_port_set_io(void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_marshal_set_position(void *object,
|
||||
uint32_t memid,
|
||||
uint32_t offset,
|
||||
uint32_t size)
|
||||
client_node_marshal_set_io(void *object,
|
||||
uint32_t id,
|
||||
uint32_t memid,
|
||||
uint32_t offset,
|
||||
uint32_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_builder *b;
|
||||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_POSITION);
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO);
|
||||
spa_pod_builder_struct(b,
|
||||
"I", id,
|
||||
"i", memid,
|
||||
"i", offset,
|
||||
"i", size);
|
||||
|
|
@ -908,6 +911,7 @@ static const struct pw_client_node_proxy_events pw_protocol_native_client_node_e
|
|||
&client_node_marshal_add_mem,
|
||||
&client_node_marshal_transport,
|
||||
&client_node_marshal_set_param,
|
||||
&client_node_marshal_set_io,
|
||||
&client_node_marshal_event_event,
|
||||
&client_node_marshal_command,
|
||||
&client_node_marshal_add_port,
|
||||
|
|
@ -916,13 +920,13 @@ static const struct pw_client_node_proxy_events pw_protocol_native_client_node_e
|
|||
&client_node_marshal_port_use_buffers,
|
||||
&client_node_marshal_port_command,
|
||||
&client_node_marshal_port_set_io,
|
||||
&client_node_marshal_set_position,
|
||||
};
|
||||
|
||||
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_event_demarshal[] = {
|
||||
{ &client_node_demarshal_add_mem, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_transport, 0 },
|
||||
{ &client_node_demarshal_set_param, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_set_io, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_event_event, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_command, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_add_port, 0 },
|
||||
|
|
@ -931,7 +935,6 @@ static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_
|
|||
{ &client_node_demarshal_port_use_buffers, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_port_command, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_port_set_io, PW_PROTOCOL_NATIVE_REMAP },
|
||||
{ &client_node_demarshal_set_position, PW_PROTOCOL_NATIVE_REMAP },
|
||||
};
|
||||
|
||||
static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue