mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-21 08:56:56 -05:00
Cleanups
Make separate _register function so that we can first configure the object before making it publicly visible.
This commit is contained in:
parent
67d4dd8656
commit
f64c28c091
25 changed files with 131 additions and 99 deletions
|
|
@ -118,11 +118,12 @@ link_state_changed(void *data, enum pw_link_state old, enum pw_link_state state,
|
|||
switch (state) {
|
||||
case PW_LINK_STATE_ERROR:
|
||||
{
|
||||
struct pw_resource *owner = pw_node_get_owner(info->node);
|
||||
struct pw_global *global = pw_node_get_global(info->node);
|
||||
struct pw_client *owner = pw_global_get_owner(global);
|
||||
|
||||
pw_log_debug("module %p: link %p: state error: %s", impl, link, error);
|
||||
if (owner)
|
||||
pw_resource_error(owner, SPA_RESULT_ERROR, error);
|
||||
pw_resource_error(pw_client_get_core_resource(owner), SPA_RESULT_ERROR, error);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -193,7 +194,6 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
}
|
||||
|
||||
link = pw_link_new(impl->core,
|
||||
pw_module_get_global(impl->module),
|
||||
port, target,
|
||||
NULL, NULL,
|
||||
&error,
|
||||
|
|
@ -207,6 +207,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
pw_link_add_listener(link, &ld->link_listener, &link_events, ld);
|
||||
|
||||
spa_list_append(&info->links, &ld->l);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
pw_link_activate(link);
|
||||
|
||||
|
|
@ -215,9 +216,10 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod
|
|||
error:
|
||||
pw_log_error("module %p: can't link node '%s'", impl, error);
|
||||
{
|
||||
struct pw_resource *owner = pw_node_get_owner(info->node);
|
||||
struct pw_global *global = pw_node_get_global(info->node);
|
||||
struct pw_client *owner = pw_global_get_owner(global);
|
||||
if (owner)
|
||||
pw_resource_error(owner, SPA_RESULT_ERROR, error);
|
||||
pw_resource_error(pw_client_get_core_resource(owner), SPA_RESULT_ERROR, error);
|
||||
}
|
||||
free(error);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1161,7 +1161,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
|||
|
||||
this->resource = resource;
|
||||
this->node = pw_spa_node_new(core,
|
||||
this->resource,
|
||||
pw_resource_get_client(this->resource),
|
||||
NULL,
|
||||
name,
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -796,7 +796,6 @@ handle_connect_name_ports(struct client *client)
|
|||
pw_log_debug("protocol-jack %p: connected ports %p %p", impl, out_port, in_port);
|
||||
|
||||
link = pw_link_new(impl->core,
|
||||
pw_module_get_global(impl->module),
|
||||
out_port->port,
|
||||
in_port->port,
|
||||
NULL,
|
||||
|
|
@ -810,6 +809,7 @@ handle_connect_name_ports(struct client *client)
|
|||
ld->in_port = in_port;
|
||||
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);
|
||||
|
|
@ -1038,8 +1038,7 @@ static struct client *client_new(struct impl *impl, int fd)
|
|||
if (properties == NULL)
|
||||
goto no_props;
|
||||
|
||||
client = pw_client_new(impl->core, pw_module_get_global(impl->module),
|
||||
ucredp, properties, sizeof(struct client));
|
||||
client = pw_client_new(impl->core, ucredp, properties, sizeof(struct client));
|
||||
if (client == NULL)
|
||||
goto no_client;
|
||||
|
||||
|
|
@ -1058,6 +1057,8 @@ static struct client *client_new(struct impl *impl, int fd)
|
|||
|
||||
pw_client_add_listener(client, &this->client_listener, &client_events, this);
|
||||
|
||||
pw_client_register(client, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
pw_log_debug("module-jack %p: added new client", impl);
|
||||
|
||||
return this;
|
||||
|
|
@ -1277,7 +1278,6 @@ make_freewheel_client(struct impl *impl)
|
|||
}
|
||||
|
||||
static bool on_global(void *data, struct pw_global *global)
|
||||
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct pw_node *node;
|
||||
|
|
@ -1302,7 +1302,7 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
if (out_port == NULL || in_port == NULL)
|
||||
return true;
|
||||
|
||||
impl->sink_link = pw_link_new(impl->core, pw_module_get_global(impl->module),
|
||||
impl->sink_link = pw_link_new(impl->core,
|
||||
out_port,
|
||||
in_port,
|
||||
NULL,
|
||||
|
|
@ -1310,6 +1310,7 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
NULL,
|
||||
0);
|
||||
pw_link_inc_idle(impl->sink_link);
|
||||
pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ struct pw_jack_node *pw_jack_node_new(struct pw_core *core,
|
|||
}
|
||||
pw_properties_setf(properties, "jack.ref-num", "%d", ref_num);
|
||||
|
||||
node = pw_node_new(core, NULL, parent, name, properties, sizeof(struct node_data) + user_data_size);
|
||||
node = pw_node_new(core, name, properties, sizeof(struct node_data) + user_data_size);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -917,7 +917,7 @@ struct pw_jack_node *pw_jack_node_new(struct pw_core *core,
|
|||
jack_connection_manager_init_ref_num(conn, ref_num);
|
||||
jack_graph_manager_next_stop(mgr);
|
||||
|
||||
pw_node_register(node);
|
||||
pw_node_register(node, NULL, parent);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
@ -960,7 +960,7 @@ pw_jack_driver_new(struct pw_core *core,
|
|||
}
|
||||
pw_properties_setf(properties, "jack.ref-num", "%d", ref_num);
|
||||
|
||||
node = pw_node_new(core, NULL, parent, name, properties, sizeof(struct node_data) + user_data_size);
|
||||
node = pw_node_new(core, name, properties, sizeof(struct node_data) + user_data_size);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -1013,7 +1013,7 @@ pw_jack_driver_new(struct pw_core *core,
|
|||
this->driver_out = alloc_port(this, PW_DIRECTION_OUTPUT, 0);
|
||||
pw_port_add(this->driver_out->port, node);
|
||||
}
|
||||
pw_node_register(node);
|
||||
pw_node_register(node, NULL, parent);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,8 +161,9 @@ static bool on_global(void *data, struct pw_global *global)
|
|||
if (op == NULL)
|
||||
return true;
|
||||
|
||||
link = pw_link_new(impl->core, pw_module_get_global(impl->module), op, ip, NULL, NULL, &error, 0);
|
||||
link = pw_link_new(impl->core, op, ip, NULL, NULL, &error, 0);
|
||||
pw_link_inc_idle(link);
|
||||
pw_link_register(link, NULL, pw_module_get_global(impl->module));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ static struct client *client_new(struct impl *impl, const char *sender)
|
|||
struct client *this;
|
||||
struct pw_client *client;
|
||||
|
||||
client = pw_client_new(impl->core, NULL, NULL);
|
||||
client = pw_client_new(impl->core, NULL, NULL, 0);
|
||||
|
||||
if ((this = (struct client *) find_object(impl, client))) {
|
||||
pipewire_client1_set_sender(this->parent.iface, sender);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ process_messages(struct client_data *data)
|
|||
pw_log_trace("protocol-native %p: got message %d from %u", client->protocol,
|
||||
opcode, id);
|
||||
|
||||
resource = pw_client_get_resource(client, id);
|
||||
resource = pw_client_find_resource(client, id);
|
||||
if (resource == NULL) {
|
||||
pw_log_error("protocol-native %p: unknown resource %u",
|
||||
client->protocol, id);
|
||||
|
|
@ -246,7 +246,6 @@ static struct pw_client *client_new(struct server *s, int fd)
|
|||
goto no_props;
|
||||
|
||||
client = pw_client_new(protocol->core,
|
||||
pw_module_get_global(pd->module),
|
||||
ucredp,
|
||||
props,
|
||||
sizeof(struct client_data));
|
||||
|
|
@ -268,6 +267,7 @@ static struct pw_client *client_new(struct server *s, int fd)
|
|||
spa_list_append(&s->this.client_list, &client->protocol_link);
|
||||
|
||||
pw_client_add_listener(client, &this->client_listener, &client_events, this);
|
||||
pw_client_register(client, NULL, pw_module_get_global(pd->module));
|
||||
|
||||
pw_global_bind(pw_core_get_global(core), client, PW_PERM_RWX, PW_VERSION_CORE, 0);
|
||||
|
||||
|
|
@ -491,7 +491,7 @@ on_remote_data(void *data, int fd, enum spa_io mask)
|
|||
|
||||
pw_log_trace("protocol-native %p: got message %d from %u", this, opcode, id);
|
||||
|
||||
proxy = pw_remote_get_proxy(this, id);
|
||||
proxy = pw_remote_find_proxy(this, id);
|
||||
|
||||
if (proxy == NULL) {
|
||||
pw_log_error("protocol-native %p: could not find proxy %u", this, id);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
struct impl {
|
||||
struct pw_node *this;
|
||||
|
||||
struct pw_client *owner;
|
||||
struct pw_global *parent;
|
||||
|
||||
bool async_init;
|
||||
|
||||
void *hnd;
|
||||
|
|
@ -68,7 +71,7 @@ static void pw_spa_node_destroy(void *data)
|
|||
static void complete_init(struct impl *impl)
|
||||
{
|
||||
struct pw_node *this = impl->this;
|
||||
pw_node_register(this);
|
||||
pw_node_register(this, impl->owner, impl->parent);
|
||||
}
|
||||
|
||||
static void on_node_done(void *data, uint32_t seq, int res)
|
||||
|
|
@ -91,7 +94,7 @@ static const struct pw_node_events node_events = {
|
|||
|
||||
struct pw_node *
|
||||
pw_spa_node_new(struct pw_core *core,
|
||||
struct pw_resource *owner,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
const char *name,
|
||||
bool async,
|
||||
|
|
@ -103,7 +106,7 @@ pw_spa_node_new(struct pw_core *core,
|
|||
struct pw_node *this;
|
||||
struct impl *impl;
|
||||
|
||||
this = pw_node_new(core, owner, parent, name, properties, sizeof(struct impl) + user_data_size);
|
||||
this = pw_node_new(core, name, properties, sizeof(struct impl) + user_data_size);
|
||||
if (this == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -111,6 +114,8 @@ pw_spa_node_new(struct pw_core *core,
|
|||
|
||||
impl = this->user_data;
|
||||
impl->this = this;
|
||||
impl->owner = owner;
|
||||
impl->parent = parent;
|
||||
impl->node = node;
|
||||
impl->async_init = async;
|
||||
|
||||
|
|
@ -187,7 +192,7 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
|
|||
|
||||
|
||||
struct pw_node *pw_spa_node_load(struct pw_core *core,
|
||||
struct pw_resource *owner,
|
||||
struct pw_client *owner,
|
||||
struct pw_global *parent,
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ extern "C" {
|
|||
|
||||
struct pw_node *
|
||||
pw_spa_node_new(struct pw_core *core,
|
||||
struct pw_resource *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< optional parent */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< optional parent */
|
||||
const char *name,
|
||||
bool async,
|
||||
struct spa_node *node,
|
||||
|
|
@ -43,8 +43,8 @@ pw_spa_node_new(struct pw_core *core,
|
|||
|
||||
struct pw_node *
|
||||
pw_spa_node_load(struct pw_core *core,
|
||||
struct pw_resource *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< optional parent */
|
||||
struct pw_client *owner, /**< optional owner */
|
||||
struct pw_global *parent, /**< optional parent */
|
||||
const char *lib,
|
||||
const char *factory_name,
|
||||
const char *name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue