mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
context: add a function to merge config properties
Add a function that takes a section and merges the properties into a target properties. Replace some usage of get_config_section().
This commit is contained in:
parent
6149c01b51
commit
65c487564b
5 changed files with 24 additions and 11 deletions
|
|
@ -3150,9 +3150,8 @@ jack_client_t * jack_client_open (const char *client_name,
|
|||
client->allow_mlock = client->context.context->settings.mem_allow_mlock;
|
||||
client->warn_mlock = client->context.context->settings.mem_warn_mlock;
|
||||
|
||||
if ((str = pw_context_get_conf_section(client->context.context,
|
||||
"jack.properties")) != NULL)
|
||||
pw_properties_update_string(client->props, str, strlen(str));
|
||||
pw_context_conf_update_props(client->context.context,
|
||||
"jack.properties", client->props);
|
||||
|
||||
if ((str = getenv("PIPEWIRE_PROPS")) != NULL)
|
||||
pw_properties_update_string(client->props, str, strlen(str));
|
||||
|
|
|
|||
|
|
@ -273,10 +273,8 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
|
|||
n_support = pw_get_support(this->support, SPA_N_ELEMENTS(this->support) - 6);
|
||||
cpu = spa_support_find(this->support, n_support, SPA_TYPE_INTERFACE_CPU);
|
||||
|
||||
if ((str = pw_properties_get(conf, "context.properties")) != NULL) {
|
||||
pw_properties_update_string(properties, str, strlen(str));
|
||||
pw_log_info("%p: parsed context.properties section", this);
|
||||
}
|
||||
res = pw_context_conf_update_props(this, "context.properties", properties);
|
||||
pw_log_info("%p: parsed %d context.properties items", this, res);
|
||||
|
||||
if ((str = getenv("PIPEWIRE_CORE"))) {
|
||||
pw_log_info("using core.name from environment: %s", str);
|
||||
|
|
@ -539,6 +537,20 @@ const char *pw_context_get_conf_section(struct pw_context *context, const char *
|
|||
return pw_properties_get(context->conf, section);
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_context_conf_update_props(struct pw_context *context,
|
||||
const char *section, struct pw_properties *props)
|
||||
{
|
||||
struct pw_properties *conf = context->conf;
|
||||
const char *str;
|
||||
int count = 0;
|
||||
|
||||
if ((str = pw_properties_get(conf, section)) != NULL)
|
||||
count = pw_properties_update_string(props, str, strlen(str));
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/** Update context properties
|
||||
*
|
||||
* \param context a context
|
||||
|
|
|
|||
|
|
@ -111,6 +111,10 @@ int pw_context_update_properties(struct pw_context *context, const struct spa_di
|
|||
/** Get a config section for this context. Since 0.3.22 */
|
||||
const char *pw_context_get_conf_section(struct pw_context *context, const char *section);
|
||||
|
||||
/** update properties from section into props. Since 0.3.45 */
|
||||
int pw_context_conf_update_props(struct pw_context *context, const char *section,
|
||||
struct pw_properties *props);
|
||||
|
||||
/** Get the context support objects */
|
||||
const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);
|
||||
|
||||
|
|
|
|||
|
|
@ -1209,8 +1209,7 @@ filter_new(struct pw_context *context, const char *name,
|
|||
res = -errno;
|
||||
goto error_properties;
|
||||
}
|
||||
if ((str = pw_context_get_conf_section(context, "filter.properties")) != NULL)
|
||||
pw_properties_update_string(props, str, strlen(str));
|
||||
pw_context_conf_update_props(context, "filter.properties", props);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL && extra) {
|
||||
str = pw_properties_get(extra, PW_KEY_APP_NAME);
|
||||
|
|
|
|||
|
|
@ -1342,8 +1342,7 @@ stream_new(struct pw_context *context, const char *name,
|
|||
res = -errno;
|
||||
goto error_properties;
|
||||
}
|
||||
if ((str = pw_context_get_conf_section(context, "stream.properties")) != NULL)
|
||||
pw_properties_update_string(props, str, strlen(str));
|
||||
pw_context_conf_update_props(context, "stream.properties", props);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_STREAM_IS_LIVE) == NULL)
|
||||
pw_properties_set(props, PW_KEY_STREAM_IS_LIVE, "true");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue