mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
Simplify node activation
Don't directly expose the state change methods. Only expose an activate method for nodes that indicates if the node should be scheduled or not. Let the link automatically negotiate two active nodes. Make some defines for properties. Use link property to make passive links. Passive links don't activate the nodes. Make sure the mainloop quits when quit is called before run.
This commit is contained in:
parent
304a6d1796
commit
93a52f4837
32 changed files with 181 additions and 86 deletions
|
|
@ -169,12 +169,12 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
|
||||
props = pw_node_get_properties(node);
|
||||
|
||||
str = pw_properties_get(props, "pipewire.target.node");
|
||||
str = pw_properties_get(props, PW_NODE_PROP_TARGET_NODE);
|
||||
if (str != NULL)
|
||||
path_id = atoi(str);
|
||||
else {
|
||||
str = pw_properties_get(props, "pipewire.autoconnect");
|
||||
if (str == NULL || atoi(str) == 0) {
|
||||
str = pw_properties_get(props, PW_NODE_PROP_AUTOCONNECT);
|
||||
if (str == NULL || !pw_properties_parse_bool(str)) {
|
||||
pw_log_debug("module %p: node does not need autoconnect", impl);
|
||||
return;
|
||||
}
|
||||
|
|
@ -209,8 +209,6 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
spa_list_append(&info->links, &ld->l);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
pw_link_activate(link);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
|
|
|
|||
|
|
@ -810,7 +810,6 @@ handle_connect_name_ports(struct client *client)
|
|||
spa_list_append(&impl->link_list, &ld->link_link);
|
||||
pw_link_add_listener(link, &ld->link_listener, &link_events, ld);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
pw_link_activate(link);
|
||||
|
||||
notify_clients(impl, jack_notify_PortConnectCallback, false, "", src_id, dst_id);
|
||||
|
||||
|
|
@ -1034,7 +1033,7 @@ static struct client *client_new(struct impl *impl, int fd)
|
|||
ucredp = &ucred;
|
||||
}
|
||||
|
||||
properties = pw_properties_new("pipewire.protocol", "protocol-jack", NULL);
|
||||
properties = pw_properties_new(PW_CLIENT_PROP_PROTOCOL, "protocol-jack", NULL);
|
||||
if (properties == NULL)
|
||||
goto no_props;
|
||||
|
||||
|
|
@ -1283,6 +1282,7 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
struct pw_node *node;
|
||||
const struct pw_properties *properties;
|
||||
const char *str;
|
||||
char *error;
|
||||
struct pw_port *in_port, *out_port;
|
||||
|
||||
if (pw_global_get_type(global) != impl->t->node)
|
||||
|
|
@ -1306,10 +1306,14 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
out_port,
|
||||
in_port,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
pw_properties_new(PW_LINK_PROP_PASSIVE, "true", NULL),
|
||||
&error,
|
||||
0);
|
||||
pw_link_inc_idle(impl->sink_link);
|
||||
if (impl->sink_link == NULL) {
|
||||
pw_log_warn("can't link ports: %s", error);
|
||||
free(error);
|
||||
return true;
|
||||
}
|
||||
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -918,6 +918,7 @@ struct pw_jack_node *pw_jack_node_new(struct pw_core *core,
|
|||
jack_graph_manager_next_stop(mgr);
|
||||
|
||||
pw_node_register(node, NULL, parent);
|
||||
pw_node_set_active(node, true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
@ -1014,6 +1015,7 @@ pw_jack_driver_new(struct pw_core *core,
|
|||
pw_port_add(this->driver_out->port, node);
|
||||
}
|
||||
pw_node_register(node, NULL, parent);
|
||||
pw_node_set_active(node, true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,8 +161,12 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
if (op == NULL)
|
||||
return true;
|
||||
|
||||
link = pw_link_new(impl->core, op, ip, NULL, NULL, &error, 0);
|
||||
pw_link_inc_idle(link);
|
||||
link = pw_link_new(impl->core,
|
||||
op,
|
||||
ip,
|
||||
NULL,
|
||||
pw_properties_new(PW_LINK_PROP_PASSIVE, "true", NULL),
|
||||
&error, 0);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -365,10 +365,10 @@ handle_create_client_node(PipeWireDaemon1 * interface,
|
|||
pw_log_debug("protocol-dbus %p: create client-node: %s", impl, sender);
|
||||
props = pw_properties_from_variant(arg_properties);
|
||||
|
||||
target_node = pw_properties_get(props, "pipewire.target.node");
|
||||
target_node = pw_properties_get(props, PW_NODE_PROP_TARGET_NODE);
|
||||
if (target_node) {
|
||||
if (strncmp(target_node, "/org/pipewire/node_", strlen("/org/pipewire/node_")) == 0) {
|
||||
pw_properties_setf(props, "pipewire.target.node", "%s",
|
||||
pw_properties_setf(props, PW_NODE_PROP_TARGET_NODE, "%s",
|
||||
target_node + strlen("/org/pipewire/node_"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ static struct pw_client *client_new(struct server *s, int fd)
|
|||
ucredp = &ucred;
|
||||
}
|
||||
|
||||
props = pw_properties_new("pipewire.protocol", "protocol-native", NULL);
|
||||
props = pw_properties_new(PW_CLIENT_PROP_PROTOCOL, "protocol-native", NULL);
|
||||
if (props == NULL)
|
||||
goto no_props;
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ get_remote(const struct pw_properties *properties)
|
|||
const char *name = NULL;
|
||||
|
||||
if (properties)
|
||||
name = pw_properties_get(properties, "pipewire.remote.name");
|
||||
name = pw_properties_get(properties, PW_REMOTE_PROP_REMOTE_NAME);
|
||||
if (name == NULL)
|
||||
name = getenv("PIPEWIRE_REMOTE");
|
||||
if (name == NULL)
|
||||
|
|
@ -687,7 +687,7 @@ get_name(const struct pw_properties *properties)
|
|||
const char *name = NULL;
|
||||
|
||||
if (properties)
|
||||
name = pw_properties_get(properties, "pipewire.core.name");
|
||||
name = pw_properties_get(properties, PW_CORE_PROP_NAME);
|
||||
if (name == NULL)
|
||||
name = getenv("PIPEWIRE_CORE");
|
||||
if (name == NULL)
|
||||
|
|
@ -850,10 +850,10 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
|
|||
d->module = module;
|
||||
d->properties = properties;
|
||||
|
||||
if ((val = pw_properties_get(pw_core_get_properties(core), "pipewire.daemon"))) {
|
||||
if (atoi(val) == 1)
|
||||
if (impl_add_server(this, core, properties) == NULL)
|
||||
return false;
|
||||
val = pw_properties_get(pw_core_get_properties(core), PW_CORE_PROP_DAEMON);
|
||||
if (val && pw_properties_parse_bool(val)) {
|
||||
if (impl_add_server(this, core, properties) == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
pw_module_add_listener(module, &d->module_listener, &module_events, d);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "pipewire/log.h"
|
||||
#include "pipewire/type.h"
|
||||
#include "pipewire/module.h"
|
||||
#include "pipewire/private.h"
|
||||
|
||||
struct impl {
|
||||
struct pw_core *core;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ static void complete_init(struct impl *impl)
|
|||
{
|
||||
struct pw_node *this = impl->this;
|
||||
pw_node_register(this, impl->owner, impl->parent);
|
||||
pw_node_set_active(this, true);
|
||||
}
|
||||
|
||||
static void on_node_done(void *data, uint32_t seq, int res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue