pipewire: Add option to disable config files

Add env variable PIPEWIRE_NO_CONFIG to disable parsing
custom config files.
Add a method to check extra options.
Expose valgrind, no-config and no-color as options.
This commit is contained in:
Wim Taymans 2021-06-02 15:55:24 +02:00
parent dde03a7dd3
commit 58d0e44664
3 changed files with 29 additions and 3 deletions

View file

@ -76,6 +76,8 @@ static int get_read_path(char *path, size_t size, const char *prefix, const char
return 1;
return -ENOENT;
}
if (pw_check_option("no-config", "true"))
goto no_config;
dir = getenv("PIPEWIRE_CONFIG_DIR");
if (dir != NULL) {
@ -112,6 +114,7 @@ static int get_read_path(char *path, size_t size, const char *prefix, const char
access(path, R_OK) == 0)
return 1;
}
no_config:
dir = PIPEWIRE_CONFDATADIR;
if (dir != NULL) {
const char *paths[] = { dir, prefix, name, NULL };

View file

@ -84,6 +84,8 @@ struct support {
struct spa_support support[MAX_SUPPORT];
uint32_t n_support;
unsigned int in_valgrind:1;
unsigned int no_color:1;
unsigned int no_config:1;
};
static struct registry global_registry;
@ -487,10 +489,16 @@ void pw_init(int *argc, char **argv[])
if (support->registry != NULL)
return;
if ((str = getenv("VALGRIND")))
if ((str = getenv("VALGRIND")) != NULL)
support->in_valgrind = pw_properties_parse_bool(str);
if ((str = getenv("PIPEWIRE_DEBUG")))
if ((str = getenv("NO_COLOR")) != NULL)
support->no_color = true;
if ((str = getenv("PIPEWIRE_NO_CONFIG")) != NULL)
support->no_config = pw_properties_parse_bool(str);
if ((str = getenv("PIPEWIRE_DEBUG")) != NULL)
configure_debug(support, str);
init_i18n(support);
@ -508,7 +516,7 @@ void pw_init(int *argc, char **argv[])
if (pw_log_is_default()) {
n_items = 0;
if (getenv("NO_COLOR") == NULL)
if (!support->no_color)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_COLORS, "true");
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_TIMESTAMP, "true");
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_LOG_LINE, "true");
@ -663,6 +671,19 @@ bool pw_in_valgrind(void)
return global_support.in_valgrind;
}
SPA_EXPORT
bool pw_check_option(const char *option, const char *value)
{
if (spa_streq(option, "in-valgrind"))
return global_support.in_valgrind == spa_atob(value);
else if (spa_streq(option, "no-color"))
return global_support.no_color == spa_atob(value);
else if (spa_streq(option, "no-config"))
return global_support.no_config == spa_atob(value);
else
return false;
}
/** Get the client name
*
* Make a new PipeWire client name that can be used to construct a remote.

View file

@ -93,6 +93,8 @@ pw_get_client_name(void);
bool pw_in_valgrind(void);
bool pw_check_option(const char *option, const char *value);
enum pw_direction
pw_direction_reverse(enum pw_direction direction);