Unify props, params and formats

Make enum_params and set_param to configure properties, format
and other parameters. This allows us to remove some duplicate
code and make the properties and parameters much more extensible.
Use the object id to mark the id of the parameter.
Remove the spa_format and spa_props.
We can now make the client-node easier by merging the various
format methods into the params.
Make the stream API more powerful now that we can pass params
around.
This commit is contained in:
Wim Taymans 2017-11-07 17:39:31 +01:00
parent b6ee67905d
commit f3bca48398
87 changed files with 3773 additions and 3580 deletions

View file

@ -28,6 +28,7 @@
#include "pipewire/link.h"
#include "pipewire/log.h"
#include "pipewire/module.h"
#include "pipewire/private.h"
struct impl {
struct pw_core *core;

View file

@ -29,7 +29,6 @@
#include <sys/eventfd.h>
#include "spa/node.h"
#include "spa/format-builder.h"
#include "spa/lib/format.h"
#include "pipewire/pipewire.h"
@ -73,11 +72,10 @@ struct proxy_buffer {
struct proxy_port {
bool valid;
struct spa_port_info info;
struct spa_format *format;
uint32_t n_formats;
struct spa_format **formats;
bool have_format;
uint32_t n_params;
struct spa_param **params;
struct spa_pod_object **params;
struct spa_port_io *io;
uint32_t n_buffers;
@ -108,6 +106,9 @@ struct proxy {
struct proxy_port in_ports[MAX_INPUTS];
struct proxy_port out_ports[MAX_OUTPUTS];
uint32_t n_params;
struct spa_pod_object **params;
uint8_t format_buffer[1024];
uint32_t seq;
};
@ -145,14 +146,51 @@ static int clear_buffers(struct proxy *this, struct proxy_port *port)
return SPA_RESULT_OK;
}
static int spa_proxy_node_get_props(struct spa_node *node, struct spa_props **props)
static int spa_proxy_node_enum_params(struct spa_node *node,
uint32_t id, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
return SPA_RESULT_NOT_IMPLEMENTED;
struct proxy *this;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct proxy, node);
while (true) {
struct spa_pod_object *param;
if (*index >= this->n_params)
return SPA_RESULT_ENUM_END;
param = this->params[(*index)++];
if (param->body.id == id) {
spa_pod_builder_primitive(builder, &param->pod);
break;
}
}
return SPA_RESULT_OK;
}
static int spa_proxy_node_set_props(struct spa_node *node, const struct spa_props *props)
static int spa_proxy_node_set_param(struct spa_node *node, uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
struct proxy *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
if (this->resource == NULL)
return SPA_RESULT_OK;
pw_client_node_resource_set_param(this->resource, this->seq, id, flags, param);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static inline void do_flush(struct proxy *this)
@ -180,10 +218,10 @@ static int spa_proxy_node_send_command(struct spa_node *node, const struct spa_c
t = this->impl->t;
if (SPA_COMMAND_TYPE(command) == t->command_node.ClockUpdate) {
pw_client_node_resource_node_command(this->resource, this->seq++, command);
pw_client_node_resource_command(this->resource, this->seq++, command);
} else {
/* send start */
pw_client_node_resource_node_command(this->resource, this->seq, command);
pw_client_node_resource_command(this->resource, this->seq, command);
res = SPA_RESULT_RETURN_ASYNC(this->seq++);
}
return res;
@ -267,15 +305,12 @@ do_update_port(struct proxy *this,
enum spa_direction direction,
uint32_t port_id,
uint32_t change_mask,
uint32_t n_possible_formats,
const struct spa_format **possible_formats,
const struct spa_format *format,
uint32_t n_params,
const struct spa_param **params,
const struct spa_pod_object **params,
const struct spa_port_info *info)
{
struct proxy_port *port;
uint32_t i;
struct pw_type *t = this->impl->t;
if (direction == SPA_DIRECTION_INPUT) {
port = &this->in_ports[port_id];
@ -283,31 +318,23 @@ do_update_port(struct proxy *this,
port = &this->out_ports[port_id];
}
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_POSSIBLE_FORMATS) {
spa_log_info(this->log, "proxy %p: %d formats", this, n_possible_formats);
for (i = 0; i < port->n_formats; i++)
free(port->formats[i]);
port->n_formats = n_possible_formats;
port->formats =
realloc(port->formats, port->n_formats * sizeof(struct spa_format *));
for (i = 0; i < port->n_formats; i++)
port->formats[i] = spa_format_copy(possible_formats[i]);
}
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_FORMAT) {
spa_log_info(this->log, "proxy %p: update format %p", this, format);
if (port->format)
free(port->format);
port->format = spa_format_copy(format);
}
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_PARAMS) {
int i;
port->have_format = false;
spa_log_info(this->log, "proxy %p: update %d params", this, n_params);
for (i = 0; i < port->n_params; i++)
free(port->params[i]);
port->n_params = n_params;
port->params = realloc(port->params, port->n_params * sizeof(struct spa_param *));
for (i = 0; i < port->n_params; i++)
port->params[i] = spa_param_copy(params[i]);
port->params = realloc(port->params, port->n_params * sizeof(struct spa_pod_object *));
for (i = 0; i < port->n_params; i++) {
port->params[i] = spa_pod_object_copy(params[i]);
if (port->params[i]->body.id == t->param.idFormat)
port->have_format = true;
}
}
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO && info)
@ -315,7 +342,7 @@ do_update_port(struct proxy *this,
if (!port->valid) {
spa_log_info(this->log, "proxy %p: adding port %d", this, port_id);
port->format = NULL;
port->have_format = false;
port->valid = true;
if (direction == SPA_DIRECTION_INPUT)
@ -332,10 +359,8 @@ clear_port(struct proxy *this,
do_update_port(this,
direction,
port_id,
PW_CLIENT_NODE_PORT_UPDATE_POSSIBLE_FORMATS |
PW_CLIENT_NODE_PORT_UPDATE_FORMAT |
PW_CLIENT_NODE_PORT_UPDATE_PARAMS |
PW_CLIENT_NODE_PORT_UPDATE_INFO, 0, NULL, NULL, 0, NULL, NULL);
PW_CLIENT_NODE_PORT_UPDATE_INFO, 0, NULL, NULL);
clear_buffers(this, port);
}
@ -394,101 +419,6 @@ spa_proxy_node_remove_port(struct spa_node *node, enum spa_direction direction,
return SPA_RESULT_OK;
}
static int
spa_proxy_node_port_enum_formats(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
{
struct proxy *this;
struct proxy_port *port;
struct spa_format *fmt;
struct spa_pod_builder b = { NULL, };
int res;
uint32_t count, match = 0;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
count = match = filter ? 0 : index;
next:
if (count >= port->n_formats)
return SPA_RESULT_ENUM_END;
fmt = port->formats[count++];
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
if ((res = spa_format_filter(fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
goto next;
*format = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_format);
return SPA_RESULT_OK;
}
static int
spa_proxy_node_port_set_format(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id, uint32_t flags, const struct spa_format *format)
{
struct proxy *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (this->resource == NULL)
return SPA_RESULT_OK;
pw_client_node_resource_set_format(this->resource,
this->seq, direction, port_id, flags, format);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static int
spa_proxy_node_port_get_format(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id, const struct spa_format **format)
{
struct proxy *this;
struct proxy_port *port;
if (node == NULL || format == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
if (!port->format)
return SPA_RESULT_NO_FORMAT;
*format = port->format;
return SPA_RESULT_OK;
}
static int
spa_proxy_node_port_get_info(struct spa_node *node,
enum spa_direction direction,
@ -515,14 +445,17 @@ spa_proxy_node_port_get_info(struct spa_node *node,
static int
spa_proxy_node_port_enum_params(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id, uint32_t index, struct spa_param **param)
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct proxy *this;
struct proxy_port *port;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct proxy, node);
@ -531,20 +464,48 @@ spa_proxy_node_port_enum_params(struct spa_node *node,
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
if (index >= port->n_params)
return SPA_RESULT_ENUM_END;
while (true) {
struct spa_pod_object *param;
*param = port->params[index];
if (*index >= port->n_params)
return SPA_RESULT_ENUM_END;
param = port->params[(*index)++];
if (param->body.id == id) {
spa_pod_builder_primitive(builder, &param->pod);
break;
}
}
return SPA_RESULT_OK;
}
static int
spa_proxy_node_port_set_param(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id, const struct spa_param *param)
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
struct proxy *this;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = SPA_CONTAINER_OF(node, struct proxy, node);
if (!CHECK_PORT(this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (this->resource == NULL)
return SPA_RESULT_OK;
pw_client_node_resource_port_set_param(this->resource,
this->seq,
direction, port_id,
id, flags,
param);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
static int
@ -597,7 +558,7 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
if (!port->format)
if (!port->have_format)
return SPA_RESULT_NO_FORMAT;
clear_buffers(this, port);
@ -633,12 +594,12 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
mb[i].offset = 0;
mb[i].size = msh->size;
pw_client_node_resource_add_mem(this->resource,
direction,
port_id,
mb[i].mem_id,
t->data.MemFd,
msh->fd, msh->flags, msh->offset, msh->size);
pw_client_node_resource_port_add_mem(this->resource,
direction,
port_id,
mb[i].mem_id,
t->data.MemFd,
msh->fd, msh->flags, msh->offset, msh->size);
for (j = 0; j < buffers[i]->n_metas; j++) {
memcpy(&b->buffer.metas[j], &buffers[i]->metas[j], sizeof(struct spa_meta));
@ -651,13 +612,13 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
if (d->type == t->data.DmaBuf ||
d->type == t->data.MemFd) {
pw_client_node_resource_add_mem(this->resource,
direction,
port_id,
n_mem,
d->type,
d->fd,
d->flags, d->mapoffset, d->maxsize);
pw_client_node_resource_port_add_mem(this->resource,
direction,
port_id,
n_mem,
d->type,
d->fd,
d->flags, d->mapoffset, d->maxsize);
b->buffer.datas[j].type = t->data.Id;
b->buffer.datas[j].data = SPA_UINT32_TO_PTR(n_mem);
n_mem++;
@ -672,8 +633,10 @@ spa_proxy_node_port_use_buffers(struct spa_node *node,
}
}
pw_client_node_resource_use_buffers(this->resource,
this->seq, direction, port_id, n_buffers, mb);
pw_client_node_resource_port_use_buffers(this->resource,
this->seq,
direction, port_id,
n_buffers, mb);
return SPA_RESULT_RETURN_ASYNC(this->seq++);
}
@ -682,7 +645,7 @@ static int
spa_proxy_node_port_alloc_buffers(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_param **params,
struct spa_pod_object **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
@ -701,7 +664,7 @@ spa_proxy_node_port_alloc_buffers(struct spa_node *node,
port =
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
if (!port->format)
if (!port->have_format)
return SPA_RESULT_NO_FORMAT;
return SPA_RESULT_NOT_IMPLEMENTED;
@ -874,7 +837,9 @@ static void
client_node_update(void *data,
uint32_t change_mask,
uint32_t max_input_ports,
uint32_t max_output_ports, const struct spa_props *props)
uint32_t max_output_ports,
uint32_t n_params,
const struct spa_pod_object **params)
{
struct impl *impl = data;
struct proxy *this = &impl->proxy;
@ -883,7 +848,18 @@ client_node_update(void *data,
this->max_inputs = max_input_ports;
if (change_mask & PW_CLIENT_NODE_UPDATE_MAX_OUTPUTS)
this->max_outputs = max_output_ports;
if (change_mask & PW_CLIENT_NODE_UPDATE_PARAMS) {
int i;
spa_log_info(this->log, "proxy %p: update %d params", this, n_params);
for (i = 0; i < this->n_params; i++)
free(this->params[i]);
this->n_params = n_params;
this->params = realloc(this->params, this->n_params * sizeof(struct spa_pod_object *));
for (i = 0; i < this->n_params; i++)
this->params[i] = spa_pod_object_copy(params[i]);
}
spa_log_info(this->log, "proxy %p: got node update max_in %u, max_out %u", this,
this->max_inputs, this->max_outputs);
}
@ -893,11 +869,9 @@ client_node_port_update(void *data,
enum spa_direction direction,
uint32_t port_id,
uint32_t change_mask,
uint32_t n_possible_formats,
const struct spa_format **possible_formats,
const struct spa_format *format,
uint32_t n_params,
const struct spa_param **params, const struct spa_port_info *info)
const struct spa_pod_object **params,
const struct spa_port_info *info)
{
struct impl *impl = data;
struct proxy *this = &impl->proxy;
@ -916,8 +890,7 @@ client_node_port_update(void *data,
direction,
port_id,
change_mask,
n_possible_formats,
possible_formats, format, n_params, params, info);
n_params, params, info);
}
}
@ -979,17 +952,14 @@ static void proxy_on_data_fd_events(struct spa_source *source)
static const struct spa_node proxy_node = {
SPA_VERSION_NODE,
NULL,
spa_proxy_node_get_props,
spa_proxy_node_set_props,
spa_proxy_node_enum_params,
spa_proxy_node_set_param,
spa_proxy_node_send_command,
spa_proxy_node_set_callbacks,
spa_proxy_node_get_n_ports,
spa_proxy_node_get_port_ids,
spa_proxy_node_add_port,
spa_proxy_node_remove_port,
spa_proxy_node_port_enum_formats,
spa_proxy_node_port_set_format,
spa_proxy_node_port_get_format,
spa_proxy_node_port_get_info,
spa_proxy_node_port_enum_params,
spa_proxy_node_port_set_param,

View file

@ -51,18 +51,27 @@ static void
client_node_marshal_update(void *object,
uint32_t change_mask,
uint32_t max_input_ports,
uint32_t max_output_ports, const struct spa_props *props)
uint32_t max_output_ports,
uint32_t n_params,
const struct spa_pod_object **params)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
int i;
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_UPDATE);
spa_pod_builder_struct(b,
"i", change_mask,
"i", max_input_ports,
"i", max_output_ports,
"P", props);
spa_pod_builder_add(b,
"[",
"i", change_mask,
"i", max_input_ports,
"i", max_output_ports,
"i", n_params, NULL);
for (i = 0; i < n_params; i++)
spa_pod_builder_add(b, "P", params[i], NULL);
spa_pod_builder_add(b, "]", NULL);
pw_protocol_native_end_proxy(proxy, b);
}
@ -72,11 +81,9 @@ client_node_marshal_port_update(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t change_mask,
uint32_t n_possible_formats,
const struct spa_format **possible_formats,
const struct spa_format *format,
uint32_t n_params,
const struct spa_param **params, const struct spa_port_info *info)
const struct spa_pod_object **params,
const struct spa_port_info *info)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -89,13 +96,6 @@ client_node_marshal_port_update(void *object,
"i", direction,
"i", port_id,
"i", change_mask,
"i", n_possible_formats, NULL);
for (i = 0; i < n_possible_formats; i++)
spa_pod_builder_add(b, "P", possible_formats[i], NULL);
spa_pod_builder_add(b,
"P", format,
"i", n_params, NULL);
for (i = 0; i < n_params; i++)
@ -149,21 +149,57 @@ static void client_node_marshal_destroy(void *object)
pw_protocol_native_end_proxy(proxy, b);
}
static bool client_node_demarshal_set_props(void *object, void *data, size_t size)
static bool client_node_demarshal_transport(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq;
const struct spa_props *props = NULL;
uint32_t node_id, ridx, widx, memfd_idx;
int readfd, writefd;
struct pw_client_node_transport_info info;
struct pw_client_node_transport *transport;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &node_id,
"i", &ridx,
"i", &widx,
"i", &memfd_idx,
"i", &info.offset,
"i", &info.size, NULL) < 0)
return false;
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
info.memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
if (readfd == -1 || writefd == -1 || info.memfd == -1)
return false;
transport = pw_client_node_transport_new_from_info(&info);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, node_id,
readfd, writefd, transport);
return true;
}
static bool 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;
const struct spa_pod_object *param = NULL;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"O", &props, NULL) < 0)
"I", &id,
"i", &flags,
"O", &param, NULL) < 0)
return false;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_props, seq, props);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, seq, id, flags, param);
return true;
}
@ -181,6 +217,24 @@ static bool client_node_demarshal_event_event(void *object, void *data, size_t s
return true;
}
static bool 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, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"O", &command, NULL) < 0)
return false;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, seq, command);
return true;
}
static bool client_node_demarshal_add_port(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
@ -217,12 +271,12 @@ static bool client_node_demarshal_remove_port(void *object, void *data, size_t s
return true;
}
static bool client_node_demarshal_set_format(void *object, void *data, size_t size)
static bool client_node_demarshal_port_set_param(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t seq, direction, port_id, flags;
const struct spa_format *format = NULL;
uint32_t seq, direction, port_id, id, flags;
const struct spa_pod_object *param = NULL;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
@ -230,36 +284,17 @@ static bool client_node_demarshal_set_format(void *object, void *data, size_t si
"i", &seq,
"i", &direction,
"i", &port_id,
"I", &id,
"i", &flags,
"O", &format, NULL) < 0)
return false;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_format, seq, direction, port_id,
flags, format);
return true;
}
static bool 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, direction, port_id;
const struct spa_param *param = NULL;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"i", &direction,
"i", &port_id,
"O", &param, NULL) < 0)
return false;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, seq, direction, port_id, param);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param,
seq, direction, port_id, id, flags, param);
return true;
}
static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
static bool client_node_demarshal_port_add_mem(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
@ -281,7 +316,7 @@ static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_mem, direction,
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_add_mem, direction,
port_id,
mem_id,
type,
@ -289,7 +324,7 @@ static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
return true;
}
static bool client_node_demarshal_use_buffers(void *object, void *data, size_t size)
static bool client_node_demarshal_port_use_buffers(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
@ -345,31 +380,13 @@ static bool client_node_demarshal_use_buffers(void *object, void *data, size_t s
d->data = SPA_UINT32_TO_PTR(data_id);
}
}
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, use_buffers, seq,
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, seq,
direction,
port_id,
n_buffers, buffers);
return true;
}
static bool client_node_demarshal_node_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, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &seq,
"O", &command, NULL) < 0)
return false;
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, node_command, seq, command);
return true;
}
static bool client_node_demarshal_port_command(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
@ -391,51 +408,42 @@ static bool client_node_demarshal_port_command(void *object, void *data, size_t
return true;
}
static bool client_node_demarshal_transport(void *object, void *data, size_t size)
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
struct pw_client_node_transport *transport)
{
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
uint32_t node_id, ridx, widx, memfd_idx;
int readfd, writefd;
struct pw_resource *resource = object;
struct spa_pod_builder *b;
struct pw_client_node_transport_info info;
struct pw_client_node_transport *transport;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
"["
"i", &node_id,
"i", &ridx,
"i", &widx,
"i", &memfd_idx,
"i", &info.offset,
"i", &info.size, NULL) < 0)
return false;
pw_client_node_transport_get_info(transport, &info);
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
info.memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
if (readfd == -1 || writefd == -1 || info.memfd == -1)
return false;
spa_pod_builder_struct(b,
"i", node_id,
"i", pw_protocol_native_add_resource_fd(resource, readfd),
"i", pw_protocol_native_add_resource_fd(resource, writefd),
"i", pw_protocol_native_add_resource_fd(resource, info.memfd),
"i", info.offset,
"i", info.size);
transport = pw_client_node_transport_new_from_info(&info);
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, node_id,
readfd, writefd, transport);
return true;
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_set_props(void *object, uint32_t seq, const struct spa_props *props)
client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PROPS);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
spa_pod_builder_struct(b,
"i", seq,
"P", props);
"I", id,
"i", flags,
"P", param);
pw_protocol_native_end_resource(resource, b);
}
@ -452,6 +460,19 @@ static void client_node_marshal_event_event(void *object, const struct spa_event
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
spa_pod_builder_struct(b, "i", seq, "P", command);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_add_port(void *object,
uint32_t seq, enum spa_direction direction, uint32_t port_id)
@ -487,61 +508,42 @@ client_node_marshal_remove_port(void *object,
}
static void
client_node_marshal_set_format(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_format *format)
client_node_marshal_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_object *param)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_FORMAT);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
spa_pod_builder_struct(b,
"i", seq,
"i", direction,
"i", port_id,
"I", id,
"i", flags,
"P", format);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_set_param(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
const struct spa_param *param)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
spa_pod_builder_struct(b,
"i", seq,
"i", direction,
"i", port_id,
"P", param);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_add_mem(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t mem_id,
uint32_t type,
int memfd, uint32_t flags, uint32_t offset, uint32_t size)
client_node_marshal_port_add_mem(void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t mem_id,
uint32_t type,
int memfd, uint32_t flags, 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_ADD_MEM);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_ADD_MEM);
spa_pod_builder_struct(b,
"i", direction,
@ -557,17 +559,17 @@ client_node_marshal_add_mem(void *object,
}
static void
client_node_marshal_use_buffers(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t n_buffers, struct pw_client_node_buffer *buffers)
client_node_marshal_port_use_buffers(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t n_buffers, struct pw_client_node_buffer *buffers)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
uint32_t i, j;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_USE_BUFFERS);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_USE_BUFFERS);
spa_pod_builder_add(b,
"[",
@ -608,19 +610,6 @@ client_node_marshal_use_buffers(void *object,
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_node_command(void *object, uint32_t seq, const struct spa_command *command)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_NODE_COMMAND);
spa_pod_builder_struct(b, "i", seq, "P", command);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_port_command(void *object,
uint32_t direction,
@ -640,28 +629,6 @@ client_node_marshal_port_command(void *object,
pw_protocol_native_end_resource(resource, b);
}
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
struct pw_client_node_transport *transport)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
struct pw_client_node_transport_info info;
pw_client_node_transport_get_info(transport, &info);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
spa_pod_builder_struct(b,
"i", node_id,
"i", pw_protocol_native_add_resource_fd(resource, readfd),
"i", pw_protocol_native_add_resource_fd(resource, writefd),
"i", pw_protocol_native_add_resource_fd(resource, info.memfd),
"i", info.offset,
"i", info.size);
pw_protocol_native_end_resource(resource, b);
}
static bool client_node_demarshal_done(void *object, void *data, size_t size)
{
@ -684,8 +651,9 @@ static bool client_node_demarshal_update(void *object, void *data, size_t size)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t change_mask, max_input_ports, max_output_ports;
const struct spa_props *props;
uint32_t change_mask, max_input_ports, max_output_ports, n_params;
const struct spa_pod_object **params;
int i;
spa_pod_parser_init(&prs, data, size, 0);
if (spa_pod_parser_get(&prs,
@ -693,13 +661,19 @@ static bool client_node_demarshal_update(void *object, void *data, size_t size)
"i", &change_mask,
"i", &max_input_ports,
"i", &max_output_ports,
"O", &props, NULL) < 0)
"i", &n_params, NULL) < 0)
return false;
params = alloca(n_params * sizeof(struct spa_pod_object *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
return false;
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, change_mask,
max_input_ports,
max_output_ports,
props);
n_params,
params);
return true;
}
@ -707,9 +681,8 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t i, direction, port_id, change_mask, n_possible_formats, n_params;
const struct spa_param **params = NULL;
const struct spa_format **possible_formats = NULL, *format = NULL;
uint32_t i, direction, port_id, change_mask, n_params;
const struct spa_pod_object **params = NULL;
struct spa_port_info info, *infop = NULL;
struct spa_pod *ipod;
@ -719,18 +692,10 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
"i", &direction,
"i", &port_id,
"i", &change_mask,
"i", &n_possible_formats, NULL) < 0)
"i", &n_params, NULL) < 0)
return false;
possible_formats = alloca(n_possible_formats * sizeof(struct spa_format *));
for (i = 0; i < n_possible_formats; i++)
if (spa_pod_parser_get(&prs, "O", &possible_formats[i], NULL) < 0)
return false;
if (spa_pod_parser_get(&prs, "O", &format, "i", &n_params, NULL) < 0)
return false;
params = alloca(n_params * sizeof(struct spa_param *));
params = alloca(n_params * sizeof(struct spa_pod_object *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
return false;
@ -753,9 +718,6 @@ static bool client_node_demarshal_port_update(void *object, void *data, size_t s
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, direction,
port_id,
change_mask,
n_possible_formats,
possible_formats,
format,
n_params,
params, infop);
return true;
@ -828,29 +790,27 @@ static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_
static const struct pw_client_node_proxy_events pw_protocol_native_client_node_event_marshal = {
PW_VERSION_CLIENT_NODE_PROXY_EVENTS,
&client_node_marshal_transport,
&client_node_marshal_set_props,
&client_node_marshal_set_param,
&client_node_marshal_event_event,
&client_node_marshal_command,
&client_node_marshal_add_port,
&client_node_marshal_remove_port,
&client_node_marshal_set_format,
&client_node_marshal_set_param,
&client_node_marshal_add_mem,
&client_node_marshal_use_buffers,
&client_node_marshal_node_command,
&client_node_marshal_port_set_param,
&client_node_marshal_port_add_mem,
&client_node_marshal_port_use_buffers,
&client_node_marshal_port_command,
};
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_event_demarshal[] = {
{ &client_node_demarshal_transport, 0 },
{ &client_node_demarshal_set_props, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_set_param, 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 },
{ &client_node_demarshal_remove_port, 0 },
{ &client_node_demarshal_set_format, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_set_param, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_add_mem, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_use_buffers, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_node_command, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_port_set_param, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_port_add_mem, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_port_use_buffers, PW_PROTOCOL_NATIVE_REMAP },
{ &client_node_demarshal_port_command, PW_PROTOCOL_NATIVE_REMAP },
};

View file

@ -434,7 +434,7 @@ do_create_link(void *data,
uint32_t output_port_id,
uint32_t input_node_id,
uint32_t input_port_id,
const struct spa_format *filter,
const struct spa_pod_object *filter,
const struct spa_dict *props,
uint32_t new_id)
{

View file

@ -1291,7 +1291,9 @@ static bool on_global(void *data, struct pw_global *global)
const char *str;
char *error;
struct pw_port *in_port, *out_port;
struct spa_props *props;
uint32_t index = 0;
uint8_t buf[2048];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
if (pw_global_get_type(global) != impl->t->node)
return true;
@ -1323,10 +1325,11 @@ static bool on_global(void *data, struct pw_global *global)
return true;
}
if (spa_node_get_props(node->node, &props) == SPA_RESULT_OK) {
if (spa_node_enum_params(node->node, SPA_ID_INVALID, &index, NULL, &b) == SPA_RESULT_OK) {
int min_latency = -1;
struct spa_pod_object *props = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
spa_props_parse(props,
spa_pod_object_parse(props,
":", impl->prop_min_latency, "?i", &min_latency, NULL);
if (min_latency != -1)

View file

@ -30,7 +30,6 @@
#include <spa/node.h>
#include <spa/hook.h>
#include <spa/format-builder.h>
#include <spa/lib/format.h>
#include <spa/audio/format-utils.h>
@ -47,6 +46,7 @@
struct type {
uint32_t format;
struct spa_type_param param;
struct spa_type_data data;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
@ -58,6 +58,7 @@ struct type {
static inline void init_type(struct type *type, struct spa_type_map *map)
{
type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
spa_type_param_map(map, &type->param);
spa_type_data_map(map, &type->data);
spa_type_media_type_map(map, &type->media_type);
spa_type_media_subtype_map(map, &type->media_subtype);
@ -121,12 +122,17 @@ struct port_data {
/** \endcond */
static int node_get_props(struct spa_node *node, struct spa_props **props)
static int node_enum_params(struct spa_node *node,
uint32_t id, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static int node_set_props(struct spa_node *node, const struct spa_props *props)
static int node_set_param(struct spa_node *node,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -368,16 +374,17 @@ static int port_set_io(struct spa_node *node, enum spa_direction direction, uint
return SPA_RESULT_OK;
}
static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
static int port_enum_formats(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl);
struct port_data *pd = nd->port_data[direction][port_id];
struct type *t = &pd->node->type;
struct spa_pod_builder b = { NULL, };
struct spa_format *fmt;
struct spa_pod_object *fmt;
uint8_t buffer[4096];
int res;
struct jack_engine_control *ctrl = pd->node->node.server->engine_control;
@ -389,55 +396,39 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction
if (pd->port.jack_port) {
if (pd->port.jack_port->type_id == 0) {
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
fmt = spa_pod_builder_object(&b,
t->param.idEnumFormat, t->format,
"I", t->media_type.audio,
"I", t->media_subtype.raw,
":", t->format_audio.format, "I", t->audio_format.F32,
":", t->format_audio.rate, "i", ctrl->sample_rate,
":", t->format_audio.channels, "i", 1);
}
else if (pd->port.jack_port->type_id == 1) {
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype_audio.midi);
fmt = spa_pod_builder_object(&b,
t->param.idEnumFormat, t->format,
"I", t->media_type.audio,
"I", t->media_subtype_audio.midi);
}
else
return SPA_RESULT_ENUM_END;
}
else {
fmt = spa_pod_builder_format(&b,
t->format,
t->media_type.audio, t->media_subtype.raw,
fmt = spa_pod_builder_object(&b,
t->param.idEnumFormat, t->format,
"I", t->media_type.audio,
"I", t->media_subtype.raw,
":", t->format_audio.format, "I", t->audio_format.S16,
":", t->format_audio.rate, "i", ctrl->sample_rate,
":", t->format_audio.channels, "i", 2);
}
spa_pod_builder_init(&b, pd->buffer, sizeof(pd->buffer));
if ((res = spa_format_filter(fmt, filter, &b)) < 0)
if ((res = spa_pod_object_filter(fmt, filter, builder)) < 0)
return res;
*format = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_format);
return SPA_RESULT_OK;
}
static int port_set_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
uint32_t flags, const struct spa_format *format)
{
return SPA_RESULT_OK;
}
static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
const struct spa_format **format)
{
int res;
struct spa_format *fmt;
res = port_enum_formats(node, direction, port_id, &fmt, NULL, 0);
*format = fmt;
return res;
}
static int port_get_info(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
const struct spa_port_info **info)
{
@ -455,14 +446,31 @@ static int port_get_info(struct spa_node *node, enum spa_direction direction, ui
return SPA_RESULT_OK;
}
static int port_enum_params(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
uint32_t index, struct spa_param **param)
static int port_enum_params(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl);
struct type *t = &nd->type;
if (id == t->param.idEnumFormat) {
return port_enum_formats(node, direction, port_id, index, filter, builder);
}
else if (id == t->param.idFormat) {
return port_enum_formats(node, direction, port_id, index, filter, builder);
}
else
return SPA_RESULT_UNKNOWN_PARAM;
return SPA_RESULT_ENUM_END;
}
static int port_set_param(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
const struct spa_param *param)
static int port_set_param(struct spa_node *node,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_OK;
}
@ -501,7 +509,7 @@ static int port_use_buffers(struct spa_node *node, enum spa_direction direction,
}
static int port_alloc_buffers(struct spa_node *node, enum spa_direction direction, uint32_t port_id,
struct spa_param **params, uint32_t n_params,
struct spa_pod_object **params, uint32_t n_params,
struct spa_buffer **buffers, uint32_t *n_buffers)
{
struct node_data *nd = SPA_CONTAINER_OF(node, struct node_data, node_impl);
@ -551,17 +559,14 @@ static int port_send_command(struct spa_node *node, enum spa_direction direction
static const struct spa_node driver_impl = {
SPA_VERSION_NODE,
NULL,
.get_props = node_get_props,
.set_props = node_set_props,
.enum_params = node_enum_params,
.set_param = node_set_param,
.send_command = node_send_command,
.set_callbacks = node_set_callbacks,
.get_n_ports = node_get_n_ports,
.get_port_ids = node_get_port_ids,
.add_port = node_add_port,
.remove_port = node_remove_port,
.port_enum_formats = port_enum_formats,
.port_set_format = port_set_format,
.port_get_format = port_get_format,
.port_get_info = port_get_info,
.port_enum_params = port_enum_params,
.port_set_param = port_set_param,
@ -577,17 +582,14 @@ static const struct spa_node driver_impl = {
static const struct spa_node node_impl = {
SPA_VERSION_NODE,
NULL,
.get_props = node_get_props,
.set_props = node_set_props,
.enum_params = node_enum_params,
.set_param = node_set_param,
.send_command = node_send_command,
.set_callbacks = node_set_callbacks,
.get_n_ports = node_get_n_ports,
.get_port_ids = node_get_port_ids,
.add_port = node_add_port,
.remove_port = node_remove_port,
.port_enum_formats = port_enum_formats,
.port_set_format = port_set_format,
.port_get_format = port_get_format,
.port_get_info = port_get_info,
.port_enum_params = port_enum_params,
.port_set_param = port_set_param,

View file

@ -99,6 +99,7 @@ struct client_data {
static bool pod_remap_data(uint32_t type, void *body, uint32_t size, struct pw_map *types)
{
void *t;
switch (type) {
case SPA_POD_TYPE_ID:
if ((t = pw_map_lookup(types, *(int32_t *) body)) == NULL)
@ -131,6 +132,11 @@ static bool pod_remap_data(uint32_t type, void *body, uint32_t size, struct pw_m
struct spa_pod_object_body *b = body;
struct spa_pod *p;
if ((t = pw_map_lookup(types, b->id)) != NULL)
b->id = PW_MAP_PTR_TO_ID(t);
else
b->id = SPA_ID_INVALID;
if ((t = pw_map_lookup(types, b->type)) == NULL)
return false;
b->type = PW_MAP_PTR_TO_ID(t);
@ -211,7 +217,7 @@ process_messages(struct client_data *data)
if (!pod_remap_data(SPA_POD_TYPE_STRUCT, message, size, &client->types))
goto invalid_message;
if (!demarshal[opcode].func (resource, message, size))
if (!demarshal[opcode].func(resource, message, size))
goto invalid_message;
}
return;

View file

@ -322,7 +322,7 @@ pw_protocol_native_connection_get_next(struct pw_protocol_native_connection *con
if (debug_messages) {
printf("<<<<<<<<< in: %d %d %zd\n", *dest_id, *opcode, len);
spa_debug_pod((struct spa_pod *)data);
spa_debug_pod((struct spa_pod *)data, 0);
}
return true;
@ -428,7 +428,7 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
if (debug_messages) {
printf(">>>>>>>>> out: %d %d %d\n", impl->dest_id, impl->opcode, size);
spa_debug_pod((struct spa_pod *)p);
spa_debug_pod((struct spa_pod *)p, 0);
}
spa_hook_list_call(&conn->listener_list, struct pw_protocol_native_connection_events, need_flush);
}

View file

@ -117,7 +117,7 @@ core_marshal_create_link(void *object,
uint32_t output_port_id,
uint32_t input_node_id,
uint32_t input_port_id,
const struct spa_format *filter,
const struct spa_pod_object *filter,
const struct spa_dict *props,
uint32_t new_id)
{
@ -463,7 +463,7 @@ static bool core_demarshal_create_link(void *object, void *data, size_t size)
struct spa_pod_parser prs;
uint32_t new_id, i;
uint32_t output_node_id, output_port_id, input_node_id, input_port_id;
struct spa_format *filter = NULL;
struct spa_pod_object *filter = NULL;
struct spa_dict props;
spa_pod_parser_init(&prs, data, size, 0);
@ -703,18 +703,18 @@ static void node_marshal_info(void *object, struct pw_node_info *info)
"s", info->name,
"i", info->max_input_ports,
"i", info->n_input_ports,
"i", info->n_input_formats, NULL);
"i", info->n_input_params, NULL);
for (i = 0; i < info->n_input_formats; i++)
spa_pod_builder_add(b, "P", info->input_formats[i], NULL);
for (i = 0; i < info->n_input_params; i++)
spa_pod_builder_add(b, "P", info->input_params[i], NULL);
spa_pod_builder_add(b,
"i", info->max_output_ports,
"i", info->n_output_ports,
"i", info->n_output_formats, 0);
"i", info->n_output_params, 0);
for (i = 0; i < info->n_output_formats; i++)
spa_pod_builder_add(b, "P", info->output_formats[i], NULL);
for (i = 0; i < info->n_output_params; i++)
spa_pod_builder_add(b, "P", info->output_params[i], NULL);
n_items = info->props ? info->props->n_items : 0;
@ -748,23 +748,23 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
"s", &info.name,
"i", &info.max_input_ports,
"i", &info.n_input_ports,
"i", &info.n_input_formats, NULL) < 0)
"i", &info.n_input_params, NULL) < 0)
return false;
info.input_formats = alloca(info.n_input_formats * sizeof(struct spa_format *));
for (i = 0; i < info.n_input_formats; i++)
if (spa_pod_parser_get(&prs, "P", &info.input_formats[i], NULL) < 0)
info.input_params = alloca(info.n_input_params * sizeof(struct spa_pod_object *));
for (i = 0; i < info.n_input_params; i++)
if (spa_pod_parser_get(&prs, "P", &info.input_params[i], NULL) < 0)
return false;
if (spa_pod_parser_get(&prs,
"i", &info.max_output_ports,
"i", &info.n_output_ports,
"i", &info.n_output_formats, NULL) < 0)
"i", &info.n_output_params, NULL) < 0)
return false;
info.output_formats = alloca(info.n_output_formats * sizeof(struct spa_format *));
for (i = 0; i < info.n_output_formats; i++)
if (spa_pod_parser_get(&prs, "P", &info.output_formats[i], NULL) < 0)
info.output_params = alloca(info.n_output_params * sizeof(struct spa_pod_object *));
for (i = 0; i < info.n_output_params; i++)
if (spa_pod_parser_get(&prs, "P", &info.output_params[i], NULL) < 0)
return false;
if (spa_pod_parser_get(&prs,

View file

@ -154,15 +154,19 @@ static int
setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_properties *pw_props)
{
int res;
struct spa_props *props;
struct spa_pod_object *props;
void *state = NULL;
const char *key;
struct pw_type *t = pw_core_get_type(core);
uint32_t index = 0;
uint8_t buf[2048];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
if ((res = spa_node_get_props(spa_node, &props)) != SPA_RESULT_OK) {
if ((res = spa_node_enum_params(spa_node, t->param.idProps, &index, NULL, &b)) != SPA_RESULT_OK) {
pw_log_debug("spa_node_get_props failed: %d", res);
return SPA_RESULT_ERROR;
}
props = SPA_POD_BUILDER_DEREF(&b, 0, struct spa_pod_object);
while ((key = pw_properties_iterate(pw_props, &state))) {
struct spa_pod_prop *prop;
@ -175,7 +179,7 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
if (id == SPA_ID_INVALID)
continue;
if ((prop = spa_pod_object_find_prop(&props->object, id))) {
if ((prop = spa_pod_object_find_prop(props, id))) {
const char *value = pw_properties_get(pw_props, key);
pw_log_info("configure prop %s", key);
@ -213,7 +217,7 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
}
}
if ((res = spa_node_set_props(spa_node, props)) != SPA_RESULT_OK) {
if ((res = spa_node_set_param(spa_node, t->param.idProps, 0, props)) != SPA_RESULT_OK) {
pw_log_debug("spa_node_set_props failed: %d", res);
return SPA_RESULT_ERROR;
}