mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pass spa_dict around as config
Don't pass pw_properties around when we simply need to pass around config info, only use pw_properties when used to construct an object that keeps the properties.
This commit is contained in:
parent
3eec3f5abf
commit
1317ca140c
20 changed files with 73 additions and 68 deletions
|
|
@ -142,7 +142,7 @@ static struct node *create_node(struct object *obj, uint32_t id,
|
|||
node->handle = handle;
|
||||
node->node = iface;
|
||||
node->proxy = pw_core_export(impl->core,
|
||||
info->type, pw_properties_new_dict(info->props), node->node, 0);
|
||||
info->type, info->props, node->node, 0);
|
||||
if (node->proxy == NULL)
|
||||
goto clean_node;
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ static struct object *create_object(struct impl *impl, uint32_t id,
|
|||
obj->handle = handle;
|
||||
obj->device = iface;
|
||||
obj->proxy = pw_core_export(impl->core,
|
||||
info->type, pw_properties_new_dict(info->props), obj->device, 0);
|
||||
info->type, info->props, obj->device, 0);
|
||||
if (obj->proxy == NULL)
|
||||
goto clean_object;
|
||||
|
||||
|
|
|
|||
|
|
@ -474,7 +474,9 @@ static void make_node(struct data *data)
|
|||
SPA_TYPE_INTERFACE_Node,
|
||||
SPA_VERSION_NODE,
|
||||
&impl_node, data);
|
||||
pw_core_export(data->core, SPA_TYPE_INTERFACE_Node, props, &data->impl_node, 0);
|
||||
pw_core_export(data->core, SPA_TYPE_INTERFACE_Node,
|
||||
&props->dict, &data->impl_node, 0);
|
||||
pw_properties_free(props);
|
||||
}
|
||||
|
||||
static void set_permissions(struct data *data)
|
||||
|
|
|
|||
|
|
@ -482,7 +482,9 @@ static void make_node(struct data *data)
|
|||
SPA_TYPE_INTERFACE_Node,
|
||||
SPA_VERSION_NODE,
|
||||
&impl_node, data);
|
||||
pw_core_export(data->core, SPA_TYPE_INTERFACE_Node, props, &data->impl_node, 0);
|
||||
pw_core_export(data->core, SPA_TYPE_INTERFACE_Node,
|
||||
&props->dict, &data->impl_node, 0);
|
||||
pw_properties_free(props);
|
||||
}
|
||||
|
||||
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
|
||||
|
|
|
|||
|
|
@ -92,8 +92,10 @@ static int make_node(struct data *data)
|
|||
}
|
||||
|
||||
data->proxy = pw_core_export(data->core,
|
||||
SPA_TYPE_INTERFACE_Node, props,
|
||||
SPA_TYPE_INTERFACE_Node, &props->dict,
|
||||
data->node, 0);
|
||||
pw_properties_free(props);
|
||||
|
||||
if (data->proxy == NULL)
|
||||
return -errno;
|
||||
|
||||
|
|
|
|||
|
|
@ -583,8 +583,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
|
|||
update_device_props(device);
|
||||
|
||||
device->sdevice = sm_media_session_export_device(impl->session,
|
||||
pw_properties_copy(device->props),
|
||||
device->device);
|
||||
&device->props->dict, device->device);
|
||||
if (device->sdevice == NULL) {
|
||||
res = -errno;
|
||||
goto clean_device;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_
|
|||
}
|
||||
node->proxy = sm_media_session_export(impl->session,
|
||||
PW_TYPE_INTERFACE_Node,
|
||||
pw_properties_copy(node->props),
|
||||
&node->props->dict,
|
||||
node->adapter, 0);
|
||||
|
||||
spa_list_append(&obj->node_list, &node->link);
|
||||
|
|
@ -276,7 +276,7 @@ static struct bluez5_object *bluez5_create_object(struct impl *impl, uint32_t id
|
|||
obj->device = iface;
|
||||
obj->props = pw_properties_new_dict(info->props);
|
||||
obj->proxy = sm_media_session_export(impl->session,
|
||||
info->type, pw_properties_copy(obj->props), obj->device, 0);
|
||||
info->type, &obj->props->dict, obj->device, 0);
|
||||
if (obj->proxy == NULL) {
|
||||
res = -errno;
|
||||
goto clean_object;
|
||||
|
|
|
|||
|
|
@ -1210,16 +1210,16 @@ static const struct pw_registry_events registry_events = {
|
|||
};
|
||||
|
||||
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
|
||||
uint32_t type, struct pw_properties *properties,
|
||||
uint32_t type, const struct spa_dict *props,
|
||||
void *object, size_t user_data_size)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
|
||||
return pw_core_export(impl->monitor_core, type,
|
||||
properties, object, user_data_size);
|
||||
props, object, user_data_size);
|
||||
}
|
||||
|
||||
struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
|
||||
struct pw_properties *properties, struct spa_device *object)
|
||||
const struct spa_dict *props, struct spa_device *object)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
|
||||
struct sm_device *device;
|
||||
|
|
@ -1228,9 +1228,9 @@ struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
|
|||
pw_log_debug(NAME " %p: device %p", impl, object);
|
||||
|
||||
proxy = pw_core_export(impl->monitor_core, SPA_TYPE_INTERFACE_Device,
|
||||
properties, object, sizeof(struct sm_device));
|
||||
props, object, sizeof(struct sm_device));
|
||||
|
||||
device = (struct sm_device *) create_object(impl, proxy, &properties->dict);
|
||||
device = (struct sm_device *) create_object(impl, proxy, props);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,11 +218,11 @@ struct sm_object *sm_media_session_find_object(struct sm_media_session *sess, ui
|
|||
int sm_media_session_schedule_rescan(struct sm_media_session *sess);
|
||||
|
||||
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
|
||||
uint32_t type, struct pw_properties *properties,
|
||||
uint32_t type, const struct spa_dict *props,
|
||||
void *object, size_t user_data_size);
|
||||
|
||||
struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
|
||||
struct pw_properties *properties, struct spa_device *device);
|
||||
const struct spa_dict *props, struct spa_device *device);
|
||||
|
||||
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
|
||||
const char *factory_name, uint32_t type, uint32_t version,
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ static struct v4l2_object *v4l2_create_object(struct impl *impl, uint32_t id,
|
|||
v4l2_update_device_props(obj);
|
||||
|
||||
obj->proxy = sm_media_session_export(impl->session,
|
||||
info->type, pw_properties_copy(obj->props), obj->device, 0);
|
||||
info->type, &obj->props->dict, obj->device, 0);
|
||||
if (obj->proxy == NULL) {
|
||||
res = -errno;
|
||||
goto clean_object;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static const struct spa_dict_item module_props[] = {
|
|||
};
|
||||
|
||||
struct pw_proxy *pw_core_spa_device_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size);
|
||||
|
||||
struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_context *context);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static const struct pw_proxy_events proxy_events = {
|
|||
};
|
||||
|
||||
struct pw_proxy *pw_core_spa_device_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct spa_device *device = object;
|
||||
|
|
@ -65,10 +65,8 @@ struct pw_proxy *pw_core_spa_device_export(struct pw_core *core,
|
|||
"client-device",
|
||||
SPA_TYPE_INTERFACE_Device,
|
||||
SPA_VERSION_DEVICE,
|
||||
props ? &props->dict : NULL,
|
||||
props,
|
||||
user_data_size + sizeof(struct device_data));
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
if (proxy == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ static const struct spa_dict_item module_props[] = {
|
|||
};
|
||||
|
||||
struct pw_proxy *pw_core_node_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
|
||||
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
|
||||
struct pw_proxy *pw_core_spa_node_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
|
||||
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
|
||||
|
||||
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_context *context);
|
||||
struct pw_protocol *pw_protocol_native_ext_client_node0_init(struct pw_context *context);
|
||||
|
|
|
|||
|
|
@ -1165,25 +1165,24 @@ static struct pw_proxy *node_export(struct pw_core *core, void *object, bool do_
|
|||
}
|
||||
|
||||
struct pw_proxy *pw_core_node_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_impl_node *node = object;
|
||||
|
||||
if (props) {
|
||||
pw_impl_node_update_properties(node, &props->dict);
|
||||
pw_properties_free(props);
|
||||
}
|
||||
if (props)
|
||||
pw_impl_node_update_properties(node, props);
|
||||
return node_export(core, object, false, user_data_size);
|
||||
}
|
||||
|
||||
struct pw_proxy *pw_core_spa_node_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_impl_node *node;
|
||||
|
||||
node = pw_context_create_node(pw_core_get_context(core), props, 0);
|
||||
node = pw_context_create_node(pw_core_get_context(core),
|
||||
props ? pw_properties_new_dict(props) : NULL, 0);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void * pw_metadata_new(struct pw_context *context, struct pw_resource *resource,
|
|||
struct pw_properties *properties);
|
||||
|
||||
struct pw_proxy *pw_core_metadata_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
|
||||
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
|
||||
|
||||
int pw_protocol_native_ext_metadata_init(struct pw_context *context);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static const struct pw_proxy_events proxy_events = {
|
|||
};
|
||||
|
||||
struct pw_proxy *pw_core_metadata_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_metadata *meta = object;
|
||||
|
|
@ -62,13 +62,11 @@ struct pw_proxy *pw_core_metadata_export(struct pw_core *core,
|
|||
struct object_data *data;
|
||||
|
||||
proxy = pw_core_create_object(core,
|
||||
"metadata",
|
||||
PW_TYPE_INTERFACE_Metadata,
|
||||
PW_VERSION_METADATA,
|
||||
props ? &props->dict : NULL,
|
||||
user_data_size + sizeof(struct object_data));
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
"metadata",
|
||||
PW_TYPE_INTERFACE_Metadata,
|
||||
PW_VERSION_METADATA,
|
||||
props,
|
||||
user_data_size + sizeof(struct object_data));
|
||||
if (proxy == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -809,7 +809,7 @@ error:
|
|||
static struct pw_protocol_client *
|
||||
impl_new_client(struct pw_protocol *protocol,
|
||||
struct pw_core *core,
|
||||
const struct pw_properties *properties)
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct client *impl;
|
||||
struct pw_protocol_client *this;
|
||||
|
|
@ -832,10 +832,10 @@ impl_new_client(struct pw_protocol *protocol,
|
|||
goto error_free;
|
||||
}
|
||||
|
||||
if (properties) {
|
||||
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
|
||||
if (props) {
|
||||
str = spa_dict_lookup(props, PW_KEY_REMOTE_INTENTION);
|
||||
if (str == NULL &&
|
||||
(str = pw_properties_get(properties, PW_KEY_REMOTE_NAME)) != NULL &&
|
||||
(str = spa_dict_lookup(props, PW_KEY_REMOTE_NAME)) != NULL &&
|
||||
strcmp(str, "internal") == 0)
|
||||
str = "internal";
|
||||
}
|
||||
|
|
@ -919,12 +919,12 @@ static const struct spa_loop_control_hooks impl_hooks = {
|
|||
};
|
||||
|
||||
static const char *
|
||||
get_name(const struct pw_properties *properties)
|
||||
get_name(const struct spa_dict *props)
|
||||
{
|
||||
const char *name = NULL;
|
||||
|
||||
if (properties)
|
||||
name = pw_properties_get(properties, PW_KEY_CORE_NAME);
|
||||
if (props)
|
||||
name = spa_dict_lookup(props, PW_KEY_CORE_NAME);
|
||||
if (name == NULL)
|
||||
name = getenv("PIPEWIRE_CORE");
|
||||
if (name == NULL)
|
||||
|
|
@ -935,7 +935,7 @@ get_name(const struct pw_properties *properties)
|
|||
static struct server *
|
||||
create_server(struct pw_protocol *protocol,
|
||||
struct pw_impl_core *core,
|
||||
const struct pw_properties *properties)
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct pw_protocol_server *this;
|
||||
struct pw_context *context = protocol->context;
|
||||
|
|
@ -964,19 +964,19 @@ create_server(struct pw_protocol *protocol,
|
|||
static struct pw_protocol_server *
|
||||
impl_add_server(struct pw_protocol *protocol,
|
||||
struct pw_impl_core *core,
|
||||
const struct pw_properties *properties)
|
||||
const struct spa_dict *props)
|
||||
{
|
||||
struct pw_protocol_server *this;
|
||||
struct server *s;
|
||||
const char *name;
|
||||
int res;
|
||||
|
||||
if ((s = create_server(protocol, core, properties)) == NULL)
|
||||
if ((s = create_server(protocol, core, props)) == NULL)
|
||||
return NULL;
|
||||
|
||||
this = &s->this;
|
||||
|
||||
name = get_name(properties);
|
||||
name = get_name(props);
|
||||
|
||||
if ((res = init_socket_name(s, name)) < 0)
|
||||
goto error;
|
||||
|
|
@ -1082,6 +1082,18 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy,
|
||||
};
|
||||
|
||||
static int need_server(struct pw_context *context, const struct spa_dict *props)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
val = getenv("PIPEWIRE_DAEMON");
|
||||
if (val == NULL)
|
||||
val = spa_dict_lookup(props, PW_KEY_CORE_DAEMON);
|
||||
if (val && pw_properties_parse_bool(val))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||
{
|
||||
|
|
@ -1089,7 +1101,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
struct pw_protocol *this;
|
||||
struct protocol_data *d;
|
||||
const struct pw_properties *props;
|
||||
const char *val;
|
||||
int res;
|
||||
|
||||
if (pw_context_find_protocol(context, PW_TYPE_INFO_PROTOCOL_Native) != NULL)
|
||||
|
|
@ -1114,13 +1125,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
d->module = module;
|
||||
|
||||
props = pw_context_get_properties(context);
|
||||
d->local = create_server(this, context->core, props);
|
||||
d->local = create_server(this, context->core, &props->dict);
|
||||
|
||||
val = getenv("PIPEWIRE_DAEMON");
|
||||
if (val == NULL)
|
||||
val = pw_properties_get(props, PW_KEY_CORE_DAEMON);
|
||||
if (val && pw_properties_parse_bool(val)) {
|
||||
if (impl_add_server(this, context->core, props) == NULL) {
|
||||
if (need_server(context, &props->dict)) {
|
||||
if (impl_add_server(this, context->core, &props->dict) == NULL) {
|
||||
res = -errno;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ struct pw_export_type {
|
|||
struct spa_list link;
|
||||
uint32_t type;
|
||||
struct pw_proxy * (*func) (struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *properties, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id)
|
|||
|
||||
SPA_EXPORT
|
||||
struct pw_proxy *pw_core_export(struct pw_core *core,
|
||||
uint32_t type, struct pw_properties *props, void *object,
|
||||
uint32_t type, const struct spa_dict *props, void *object,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct pw_proxy *proxy;
|
||||
|
|
@ -259,13 +259,10 @@ struct pw_proxy *pw_core_export(struct pw_core *core,
|
|||
|
||||
error_export_type:
|
||||
pw_log_error(NAME" %p: can't export type %d: %s", core, type, spa_strerror(res));
|
||||
goto exit_free;
|
||||
goto exit;
|
||||
error_proxy_failed:
|
||||
pw_log_error(NAME" %p: failed to create proxy: %s", core, spa_strerror(res));
|
||||
goto exit;
|
||||
exit_free:
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
exit:
|
||||
errno = -res;
|
||||
return NULL;
|
||||
|
|
@ -316,7 +313,7 @@ static struct pw_core *core_new(struct pw_context *context,
|
|||
goto error_protocol;
|
||||
}
|
||||
|
||||
p->conn = pw_protocol_new_client(protocol, p, properties);
|
||||
p->conn = pw_protocol_new_client(protocol, p, &properties->dict);
|
||||
if (p->conn == NULL)
|
||||
goto error_connection;
|
||||
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id);
|
|||
/** Export an object into the PipeWire instance associated with core */
|
||||
struct pw_proxy *pw_core_export(struct pw_core *core, /**< the core */
|
||||
uint32_t type, /**< the type of object */
|
||||
struct pw_properties *properties, /**< extra properties */
|
||||
const struct spa_dict *props, /**< extra properties */
|
||||
void *object, /**< object to export */
|
||||
size_t user_data_size /**< extra user data */);
|
||||
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ struct pw_protocol_implementaton {
|
|||
|
||||
struct pw_protocol_client * (*new_client) (struct pw_protocol *protocol,
|
||||
struct pw_core *core,
|
||||
const struct pw_properties *properties);
|
||||
const struct spa_dict *props);
|
||||
struct pw_protocol_server * (*add_server) (struct pw_protocol *protocol,
|
||||
struct pw_impl_core *core,
|
||||
const struct pw_properties *properties);
|
||||
const struct spa_dict *props);
|
||||
};
|
||||
|
||||
struct pw_protocol_events {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue