mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05: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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue