mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
modules: nmake dynamic ports work in link-factory
Just making a port and adding it to a node does not make it a working port.. Make a new node function to get a new free port, this will actually call the implementation spa_node_add_port(), which will add the new port which we can then pick up and use. See #4876
This commit is contained in:
parent
9f88d6997f
commit
1bf5ca28d8
3 changed files with 17 additions and 18 deletions
|
|
@ -279,28 +279,12 @@ static const struct pw_impl_link_events link_events = {
|
||||||
static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_direction direction)
|
static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_direction direction)
|
||||||
{
|
{
|
||||||
struct pw_impl_port *p;
|
struct pw_impl_port *p;
|
||||||
struct pw_context *context = pw_impl_node_get_context(node);
|
|
||||||
int res;
|
|
||||||
|
|
||||||
p = pw_impl_node_find_port(node, direction, PW_ID_ANY);
|
p = pw_impl_node_find_port(node, direction, PW_ID_ANY);
|
||||||
|
|
||||||
if (p == NULL || pw_impl_port_is_linked(p)) {
|
if (p == NULL || pw_impl_port_is_linked(p))
|
||||||
uint32_t port_id;
|
p = pw_impl_node_get_free_port(node, direction);
|
||||||
|
|
||||||
port_id = pw_impl_node_get_free_port_id(node, direction);
|
|
||||||
if (port_id == SPA_ID_INVALID)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
p = pw_context_create_port(context, direction, port_id, NULL, 0);
|
|
||||||
if (p == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if ((res = pw_impl_port_add(p, node)) < 0) {
|
|
||||||
pw_log_warn("can't add port: %s", spa_strerror(res));
|
|
||||||
errno = -res;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2709,6 +2709,19 @@ error:
|
||||||
return SPA_ID_INVALID;
|
return SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
struct pw_impl_port *pw_impl_node_get_free_port(struct pw_impl_node *node, enum pw_direction direction)
|
||||||
|
{
|
||||||
|
uint32_t port_id = pw_impl_node_get_free_port_id(node, direction);
|
||||||
|
if (port_id == SPA_ID_INVALID)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
spa_node_add_port(node->node, direction, port_id, NULL);
|
||||||
|
|
||||||
|
return pw_impl_node_find_port(node, direction, port_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void on_state_complete(void *obj, void *data, int res, uint32_t seq)
|
static void on_state_complete(void *obj, void *data, int res, uint32_t seq)
|
||||||
{
|
{
|
||||||
struct pw_impl_node *node = obj;
|
struct pw_impl_node *node = obj;
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,8 @@ pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, u
|
||||||
|
|
||||||
/** Get a free unused port_id from the node */
|
/** Get a free unused port_id from the node */
|
||||||
uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
|
uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
|
||||||
|
/** Get a free unused port from the node */
|
||||||
|
struct pw_impl_port *pw_impl_node_get_free_port(struct pw_impl_node *node, enum pw_direction direction);
|
||||||
|
|
||||||
int pw_impl_node_initialized(struct pw_impl_node *node);
|
int pw_impl_node_initialized(struct pw_impl_node *node);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue