mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
client-node: fix port implementation
Make the port forward the port methods to the node. Fix io area when not using adapter
This commit is contained in:
parent
ca898a00db
commit
57ef49b154
2 changed files with 57 additions and 24 deletions
|
|
@ -106,12 +106,13 @@ struct mix {
|
||||||
|
|
||||||
struct port {
|
struct port {
|
||||||
struct pw_port *port;
|
struct pw_port *port;
|
||||||
|
struct node *node;
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
|
|
||||||
enum spa_direction direction;
|
enum spa_direction direction;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
struct spa_node node;
|
struct spa_node mix_node;
|
||||||
|
|
||||||
struct spa_port_info info;
|
struct spa_port_info info;
|
||||||
struct pw_properties *properties;
|
struct pw_properties *properties;
|
||||||
|
|
@ -661,9 +662,7 @@ impl_node_port_set_param(struct spa_node *node,
|
||||||
|
|
||||||
this = SPA_CONTAINER_OF(node, struct node, node);
|
this = SPA_CONTAINER_OF(node, struct node, node);
|
||||||
|
|
||||||
pw_log_debug(". %p %d %d", this, direction, port_id);
|
|
||||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||||
pw_log_debug(".");
|
|
||||||
|
|
||||||
if (this->resource == NULL)
|
if (this->resource == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1363,10 +1362,34 @@ static const struct pw_port_implementation port_impl = {
|
||||||
.release_mix = port_release_mix,
|
.release_mix = port_release_mix,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
impl_mix_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 *filter,
|
||||||
|
struct spa_pod **result,
|
||||||
|
struct spa_pod_builder *builder)
|
||||||
|
{
|
||||||
|
struct port *port = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
|
return impl_node_port_enum_params(&port->node->node, direction, port->id,
|
||||||
|
id, index, filter, result, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
impl_mix_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 *param)
|
||||||
|
{
|
||||||
|
struct port *port = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
|
return impl_node_port_set_param(&port->node->node, direction, port->id,
|
||||||
|
id, flags, param);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
impl_mix_add_port(struct spa_node *node, enum spa_direction direction, uint32_t mix_id)
|
impl_mix_add_port(struct spa_node *node, enum spa_direction direction, uint32_t mix_id)
|
||||||
{
|
{
|
||||||
struct port *port = SPA_CONTAINER_OF(node, struct port, node);
|
struct port *port = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
pw_log_debug("client-node %p: add port %d:%d.%d", node, direction, port->id, mix_id);
|
pw_log_debug("client-node %p: add port %d:%d.%d", node, direction, port->id, mix_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1374,7 +1397,7 @@ impl_mix_add_port(struct spa_node *node, enum spa_direction direction, uint32_t
|
||||||
static int
|
static int
|
||||||
impl_mix_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t mix_id)
|
impl_mix_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t mix_id)
|
||||||
{
|
{
|
||||||
struct port *port = SPA_CONTAINER_OF(node, struct port, node);
|
struct port *port = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
pw_log_debug("client-node %p: remove port %d:%d.%d", node, direction, port->id, mix_id);
|
pw_log_debug("client-node %p: remove port %d:%d.%d", node, direction, port->id, mix_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1386,7 +1409,7 @@ impl_mix_port_use_buffers(struct spa_node *node,
|
||||||
struct spa_buffer **buffers,
|
struct spa_buffer **buffers,
|
||||||
uint32_t n_buffers)
|
uint32_t n_buffers)
|
||||||
{
|
{
|
||||||
struct port *port = SPA_CONTAINER_OF(node, struct port, node);
|
struct port *port = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
struct impl *impl = port->impl;
|
struct impl *impl = port->impl;
|
||||||
|
|
||||||
return do_port_use_buffers(impl, direction, port->id, mix_id, buffers, n_buffers);
|
return do_port_use_buffers(impl, direction, port->id, mix_id, buffers, n_buffers);
|
||||||
|
|
@ -1408,7 +1431,7 @@ static int impl_mix_port_set_io(struct spa_node *node,
|
||||||
enum spa_direction direction, uint32_t mix_id,
|
enum spa_direction direction, uint32_t mix_id,
|
||||||
uint32_t id, void *data, size_t size)
|
uint32_t id, void *data, size_t size)
|
||||||
{
|
{
|
||||||
struct port *p = SPA_CONTAINER_OF(node, struct port, node);
|
struct port *p = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
struct pw_port *port = p->port;
|
struct pw_port *port = p->port;
|
||||||
struct impl *impl = port->owner_data;
|
struct impl *impl = port->owner_data;
|
||||||
struct pw_port_mix *mix;
|
struct pw_port_mix *mix;
|
||||||
|
|
@ -1430,6 +1453,22 @@ static int impl_mix_port_set_io(struct spa_node *node,
|
||||||
id, data, size);
|
id, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
impl_mix_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||||
|
{
|
||||||
|
struct port *p = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
|
return impl_node_port_reuse_buffer(&p->node->node, p->id, buffer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
impl_mix_port_send_command(struct spa_node *node,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id, const struct spa_command *command)
|
||||||
|
{
|
||||||
|
struct port *p = SPA_CONTAINER_OF(node, struct port, mix_node);
|
||||||
|
return impl_node_port_send_command(&p->node->node, direction, p->id, command);
|
||||||
|
}
|
||||||
|
|
||||||
static int impl_mix_process(struct spa_node *data)
|
static int impl_mix_process(struct spa_node *data)
|
||||||
{
|
{
|
||||||
return SPA_STATUS_HAVE_BUFFER;
|
return SPA_STATUS_HAVE_BUFFER;
|
||||||
|
|
@ -1438,21 +1477,15 @@ static int impl_mix_process(struct spa_node *data)
|
||||||
static const struct spa_node impl_port_mix = {
|
static const struct spa_node impl_port_mix = {
|
||||||
SPA_VERSION_NODE,
|
SPA_VERSION_NODE,
|
||||||
NULL,
|
NULL,
|
||||||
.enum_params = impl_node_enum_params,
|
.port_enum_params = impl_mix_port_enum_params,
|
||||||
.set_param = impl_node_set_param,
|
.port_set_param = impl_mix_port_set_param,
|
||||||
.send_command = impl_node_send_command,
|
|
||||||
.get_n_ports = impl_node_get_n_ports,
|
|
||||||
.get_port_ids = impl_node_get_port_ids,
|
|
||||||
.port_get_info = impl_node_port_get_info,
|
|
||||||
.port_enum_params = impl_node_port_enum_params,
|
|
||||||
.port_set_param = impl_node_port_set_param,
|
|
||||||
.add_port = impl_mix_add_port,
|
.add_port = impl_mix_add_port,
|
||||||
.remove_port = impl_mix_remove_port,
|
.remove_port = impl_mix_remove_port,
|
||||||
.port_use_buffers = impl_mix_port_use_buffers,
|
.port_use_buffers = impl_mix_port_use_buffers,
|
||||||
.port_alloc_buffers = impl_mix_port_alloc_buffers,
|
.port_alloc_buffers = impl_mix_port_alloc_buffers,
|
||||||
.port_set_io = impl_mix_port_set_io,
|
.port_set_io = impl_mix_port_set_io,
|
||||||
.port_reuse_buffer = impl_node_port_reuse_buffer,
|
.port_reuse_buffer = impl_mix_port_reuse_buffer,
|
||||||
.port_send_command = impl_node_port_send_command,
|
.port_send_command = impl_mix_port_send_command,
|
||||||
.process = impl_mix_process,
|
.process = impl_mix_process,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1471,10 +1504,11 @@ static void node_port_init(void *data, struct pw_port *port)
|
||||||
|
|
||||||
*p = *dummy;
|
*p = *dummy;
|
||||||
p->port = port;
|
p->port = port;
|
||||||
|
p->node = this;
|
||||||
p->direction = port->direction;
|
p->direction = port->direction;
|
||||||
p->id = port->port_id;
|
p->id = port->port_id;
|
||||||
p->impl = impl;
|
p->impl = impl;
|
||||||
p->node = impl_port_mix;
|
p->mix_node = impl_port_mix;
|
||||||
mix_init(&p->mix[MAX_MIX], p);
|
mix_init(&p->mix[MAX_MIX], p);
|
||||||
|
|
||||||
if (p->direction == SPA_DIRECTION_INPUT)
|
if (p->direction == SPA_DIRECTION_INPUT)
|
||||||
|
|
@ -1490,7 +1524,7 @@ static void node_port_added(void *data, struct pw_port *port)
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct port *p = pw_port_get_user_data(port);
|
struct port *p = pw_port_get_user_data(port);
|
||||||
|
|
||||||
pw_port_set_mix(port, &p->node,
|
pw_port_set_mix(port, &p->mix_node,
|
||||||
PW_PORT_MIX_FLAG_MULTI |
|
PW_PORT_MIX_FLAG_MULTI |
|
||||||
PW_PORT_MIX_FLAG_MIX_ONLY);
|
PW_PORT_MIX_FLAG_MIX_ONLY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -618,16 +618,13 @@ impl_node_port_set_param(struct spa_node *node,
|
||||||
impl = this->impl;
|
impl = this->impl;
|
||||||
t = impl->t;
|
t = impl->t;
|
||||||
|
|
||||||
pw_log_debug(".");
|
|
||||||
if (direction != impl->direction)
|
if (direction != impl->direction)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
pw_log_debug(".");
|
|
||||||
if ((res = spa_node_port_set_param(impl->adapter_mix, direction, port_id, id,
|
if ((res = spa_node_port_set_param(impl->adapter_mix, direction, port_id, id,
|
||||||
flags, param)) < 0)
|
flags, param)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
pw_log_debug(".");
|
|
||||||
if (id == t->param.idFormat && impl->use_converter) {
|
if (id == t->param.idFormat && impl->use_converter) {
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
if ((res = spa_node_port_set_param(impl->adapter_mix,
|
if ((res = spa_node_port_set_param(impl->adapter_mix,
|
||||||
|
|
@ -654,7 +651,7 @@ impl_node_port_set_io(struct spa_node *node,
|
||||||
struct node *this;
|
struct node *this;
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
struct pw_type *t;
|
struct pw_type *t;
|
||||||
int res;
|
int res = 0;
|
||||||
|
|
||||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||||
|
|
||||||
|
|
@ -666,7 +663,8 @@ impl_node_port_set_io(struct spa_node *node,
|
||||||
if (direction != impl->direction)
|
if (direction != impl->direction)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
res = spa_node_port_set_io(impl->adapter_mix, direction, port_id, id, data, size);
|
if (impl->use_converter)
|
||||||
|
res = spa_node_port_set_io(impl->adapter_mix, direction, port_id, id, data, size);
|
||||||
|
|
||||||
if (id == t->io.Buffers && size >= sizeof(struct spa_io_buffers)) {
|
if (id == t->io.Buffers && size >= sizeof(struct spa_io_buffers)) {
|
||||||
impl->io = data;
|
impl->io = data;
|
||||||
|
|
@ -948,6 +946,7 @@ static void client_node_initialized(void *data)
|
||||||
"audioconvert", SPA_TYPE__Node, NULL, 0, NULL)) == NULL)
|
"audioconvert", SPA_TYPE__Node, NULL, 0, NULL)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
impl->adapter_mix = impl->adapter;
|
||||||
impl->use_converter = true;
|
impl->use_converter = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue