mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
node: make port for_each more powerful
Make an int return from pw_node_for_each_port() so that we can return errors or early exit. Add pw_port_for_each_param() to iterate params. And use this to collect the formats.
This commit is contained in:
parent
425073afd8
commit
91a3670610
6 changed files with 81 additions and 47 deletions
|
|
@ -234,10 +234,10 @@ static void node_port_removed(void *data, struct pw_port *port)
|
|||
{
|
||||
}
|
||||
|
||||
static bool on_node_port_added(void *data, struct pw_port *port)
|
||||
static int on_node_port_added(void *data, struct pw_port *port)
|
||||
{
|
||||
node_port_added(data, port);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void on_node_created(struct pw_node *node, struct node_info *info)
|
||||
|
|
|
|||
|
|
@ -1067,16 +1067,16 @@ struct find_data {
|
|||
struct pw_jack_port *result;
|
||||
};
|
||||
|
||||
static bool find_port(void *data, struct pw_port *port)
|
||||
static int find_port(void *data, struct pw_port *port)
|
||||
{
|
||||
struct find_data *d = data;
|
||||
struct port_data *pd = pw_port_get_user_data(port);
|
||||
|
||||
if (pd->port.port_id == d->port_id) {
|
||||
d->result = &pd->port;
|
||||
return false;
|
||||
return 1;
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pw_jack_port *
|
||||
|
|
@ -1085,7 +1085,7 @@ pw_jack_node_find_port(struct pw_jack_node *node,
|
|||
jack_port_id_t port_id)
|
||||
{
|
||||
struct find_data data = { port_id, };
|
||||
if (!pw_node_for_each_port(node->node, direction, find_port, &data))
|
||||
if (pw_node_for_each_port(node->node, direction, find_port, &data) == 1)
|
||||
return data.result;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue