From 2bb1d88fbe5e633bed35c9b5285def0e782c1fcc Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 22 Jul 2020 11:25:19 +0200 Subject: [PATCH] keys: let env variables overwrite the keys --- src/modules/module-protocol-native.c | 7 +++---- src/modules/module-protocol-native/local-socket.c | 7 +++---- src/pipewire/keys.h | 6 ++++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 4dc774ae0..e99ed57be 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -980,12 +980,11 @@ static const struct spa_loop_control_hooks impl_hooks = { static const char * get_name(const struct spa_dict *props) { - const char *name = NULL; + const char *name; - if (props) + name = getenv("PIPEWIRE_CORE"); + if (props && name == NULL) name = spa_dict_lookup(props, PW_KEY_CORE_NAME); - if (name == NULL) - name = getenv("PIPEWIRE_CORE"); if (name == NULL) name = "pipewire-0"; return name; diff --git a/src/modules/module-protocol-native/local-socket.c b/src/modules/module-protocol-native/local-socket.c index e89ed6c27..9e87f85fb 100644 --- a/src/modules/module-protocol-native/local-socket.c +++ b/src/modules/module-protocol-native/local-socket.c @@ -39,12 +39,11 @@ static const char * get_remote(const struct spa_dict *props) { - const char *name = NULL; + const char *name; - if (props) + name = getenv("PIPEWIRE_REMOTE"); + if (props && name == NULL) name = spa_dict_lookup(props, PW_KEY_REMOTE_NAME); - if (name == NULL) - name = getenv("PIPEWIRE_REMOTE"); if (name == NULL) name = "pipewire-0"; return name; diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index 93b18d19f..ccdfd643d 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -64,7 +64,8 @@ extern "C" { /* core */ #define PW_KEY_CORE_NAME "core.name" /**< The name of the core. Default is - * pipewire-- */ + * pipewire--, overwritten + * by env(PIPEWIRE_CORE) */ #define PW_KEY_CORE_VERSION "core.version" /**< The version of the core. */ #define PW_KEY_CORE_DAEMON "core.daemon" /**< If the core is listening for connections. */ @@ -82,7 +83,8 @@ extern "C" { /* remote keys */ #define PW_KEY_REMOTE_NAME "remote.name" /**< The name of the remote to connect to, - * default env(PIPEWIRE_REMOTE) or pipewire-0 */ + * default pipewire-0, overwritten by + * env(PIPEWIRE_REMOTE) */ #define PW_KEY_REMOTE_INTENTION "remote.intention" /**< The intention of the remote connection, * "generic", "screencast" */