mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-20 00:11:31 +00:00
context: override the CORE_NAME in context
Override the CORE_NAME using the env variable in the context instead of pipewire.c. This avoids needing the _add_string() property method. Remove the properties_add_string() method, there are new improved plans for property parsing and merging: See #207
This commit is contained in:
parent
f3a98debec
commit
db245fd0ce
|
@ -65,7 +65,6 @@ int main(int argc, char *argv[])
|
|||
int c;
|
||||
char path[PATH_MAX];
|
||||
const char *config_name;
|
||||
const char *core_name;
|
||||
|
||||
if (setenv("PIPEWIRE_INTERNAL", "1", 1) < 0)
|
||||
fprintf(stderr, "can't set PIPEWIRE_INTERNAL env: %m");
|
||||
|
@ -100,11 +99,6 @@ int main(int argc, char *argv[])
|
|||
PW_KEY_CONFIG_NAME, config_name,
|
||||
NULL);
|
||||
|
||||
if ((core_name = getenv("PIPEWIRE_CORE"))) {
|
||||
pw_log_info("using core.name from environment: %s", core_name);
|
||||
pw_properties_set(properties, PW_KEY_CORE_NAME, core_name);
|
||||
}
|
||||
|
||||
loop = pw_main_loop_new(&properties->dict);
|
||||
if (loop == NULL) {
|
||||
pw_log_error("failed to create main-loop: %m");
|
||||
|
|
|
@ -250,10 +250,15 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
|
|||
cpu = spa_support_find(this->support, n_support, SPA_TYPE_INTERFACE_CPU);
|
||||
|
||||
if ((str = pw_properties_get(conf, "context.properties")) != NULL) {
|
||||
pw_properties_add_string(properties, str, strlen(str));
|
||||
pw_properties_update_string(properties, str, strlen(str));
|
||||
pw_log_info(NAME" %p: parsed context.properties section", this);
|
||||
}
|
||||
|
||||
if ((str = getenv("PIPEWIRE_CORE"))) {
|
||||
pw_log_info("using core.name from environment: %s", str);
|
||||
pw_properties_set(properties, PW_KEY_CORE_NAME, str);
|
||||
}
|
||||
|
||||
if ((str = pw_properties_get(properties, "vm.overrides")) != NULL) {
|
||||
if (cpu != NULL && spa_cpu_get_vm_type(cpu) != SPA_CPU_VM_NONE)
|
||||
pw_properties_update_string(properties, str, strlen(str));
|
||||
|
|
|
@ -146,7 +146,16 @@ struct pw_properties *pw_properties_new_dict(const struct spa_dict *dict)
|
|||
return &impl->this;
|
||||
}
|
||||
|
||||
static int update_from_string(struct pw_properties *props, const char *str, size_t size, bool overwrite)
|
||||
/** Update the properties from the given string, overwriting any
|
||||
* existing keys with the new values from \a str.
|
||||
*
|
||||
* \a str should be a whitespace separated list of key=value
|
||||
* strings or a json object, see pw_properties_new_string().
|
||||
*
|
||||
* \return The number of properties added or updated
|
||||
*/
|
||||
SPA_EXPORT
|
||||
int pw_properties_update_string(struct pw_properties *props, const char *str, size_t size)
|
||||
{
|
||||
struct properties *impl = SPA_CONTAINER_OF(props, struct properties, this);
|
||||
struct spa_json it[2];
|
||||
|
@ -175,42 +184,12 @@ static int update_from_string(struct pw_properties *props, const char *str, size
|
|||
if ((val = malloc(len+1)) != NULL)
|
||||
spa_json_parse_string(value, len, val);
|
||||
}
|
||||
if (overwrite || pw_properties_get(&impl->this, key) == NULL)
|
||||
count += pw_properties_set(&impl->this, key, val);
|
||||
count += pw_properties_set(&impl->this, key, val);
|
||||
free(val);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the properties from the given string, adding any new
|
||||
* keys from \a str but leaving existing keys in \a props unmodified.
|
||||
*
|
||||
* \a str should be a whitespace separated list of key=value
|
||||
* strings or a json object, see pw_properties_new_string().
|
||||
*
|
||||
* \return The number of properties added
|
||||
*/
|
||||
SPA_EXPORT
|
||||
int pw_properties_add_string(struct pw_properties *props, const char *str, size_t size)
|
||||
{
|
||||
return update_from_string(props, str, size, false);
|
||||
}
|
||||
|
||||
/** Update the properties from the given string, overwriting any
|
||||
* existing keys with the new values from \a str.
|
||||
*
|
||||
* \a str should be a whitespace separated list of key=value
|
||||
* strings or a json object, see pw_properties_new_string().
|
||||
*
|
||||
* \return The number of properties added or updated
|
||||
*/
|
||||
SPA_EXPORT
|
||||
int pw_properties_update_string(struct pw_properties *props, const char *str, size_t size)
|
||||
{
|
||||
return update_from_string(props, str, size, true);
|
||||
}
|
||||
|
||||
/** Make a new properties object from the given str
|
||||
*
|
||||
* \a object should be a whitespace separated list of key=value
|
||||
|
|
|
@ -74,9 +74,6 @@ int pw_properties_update(struct pw_properties *props,
|
|||
/* Update props with all key/value pairs from str */
|
||||
int pw_properties_update_string(struct pw_properties *props,
|
||||
const char *str, size_t size);
|
||||
/* Update props with only new key/value from str */
|
||||
int pw_properties_add_string(struct pw_properties *props,
|
||||
const char *str, size_t size);
|
||||
|
||||
int pw_properties_add(struct pw_properties *oldprops,
|
||||
const struct spa_dict *dict);
|
||||
|
|
Loading…
Reference in a new issue