pipewire: pw_proxy_init(): take pointer to core

`pw_proxy::core` must be initialized for `pw_proxy_init()`
to succeed, so take it as a parameter instead of relying
on the caller to initialize that field beforehand.
This commit is contained in:
Barnabás Pőcze 2023-06-25 19:47:04 +02:00
parent e299534929
commit 4bec3b56d4
3 changed files with 5 additions and 6 deletions

View file

@ -317,7 +317,6 @@ static struct pw_core *core_new(struct pw_context *context,
pw_properties_add(properties, &context->properties->dict);
p->proxy.core = p;
p->context = context;
p->properties = properties;
p->pool = pw_mempool_new(NULL);
@ -343,7 +342,7 @@ static struct pw_core *core_new(struct pw_context *context,
if (p->conn == NULL)
goto error_connection;
if ((res = pw_proxy_init(&p->proxy, PW_TYPE_INTERFACE_Core, PW_VERSION_CORE)) < 0)
if ((res = pw_proxy_init(&p->proxy, p, PW_TYPE_INTERFACE_Core, PW_VERSION_CORE)) < 0)
goto error_proxy;
p->client = (struct pw_client*)pw_proxy_new(&p->proxy,

View file

@ -1230,7 +1230,7 @@ int pw_context_debug_port_params(struct pw_context *context,
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version);
int pw_proxy_init(struct pw_proxy *proxy, struct pw_core *core, const char *type, uint32_t version);
void pw_proxy_remove(struct pw_proxy *proxy);

View file

@ -21,10 +21,11 @@ struct proxy {
};
/** \endcond */
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version)
int pw_proxy_init(struct pw_proxy *proxy, struct pw_core *core, const char *type, uint32_t version)
{
int res;
proxy->core = core;
proxy->refcount = 1;
proxy->type = type;
proxy->version = version;
@ -81,9 +82,8 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
return NULL;
this = &impl->this;
this->core = factory->core;
if ((res = pw_proxy_init(this, type, version)) < 0)
if ((res = pw_proxy_init(this, factory->core, type, version)) < 0)
goto error_init;
if (user_data_size > 0)