diff --git a/src/daemon/main.c b/src/daemon/main.c index 15e8859ea..1f0f1d352 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -32,7 +32,7 @@ #include "config.h" #include "daemon-config.h" -static const char *daemon_name = "pipewire-0"; +static const char *daemon_name = NULL; static void do_quit(void *data, int signal_number) { @@ -47,7 +47,7 @@ static void show_help(const char *name) " --version Show version\n" " -n, --name Daemon name (Default %s)\n", name, - daemon_name); + PW_DEFAULT_REMOTE); } int main(int argc, char *argv[]) @@ -68,6 +68,8 @@ int main(int argc, char *argv[]) pw_init(&argc, &argv); + daemon_name = getenv("PIPEWIRE_CORE"); + while ((c = getopt_long(argc, argv, "hVn:", long_options, NULL)) != -1) { switch (c) { case 'h' : diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index e99ed57be..f562ff493 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -978,15 +978,16 @@ static const struct spa_loop_control_hooks impl_hooks = { }; static const char * -get_name(const struct spa_dict *props) +get_server_name(const struct spa_dict *props) { - const char *name; + const char *name = NULL; - name = getenv("PIPEWIRE_CORE"); - if (props && name == NULL) + if (props) name = spa_dict_lookup(props, PW_KEY_CORE_NAME); if (name == NULL) - name = "pipewire-0"; + name = getenv("PIPEWIRE_CORE"); + if (name == NULL) + name = PW_DEFAULT_REMOTE; return name; } @@ -1034,7 +1035,7 @@ impl_add_server(struct pw_protocol *protocol, this = &s->this; - name = get_name(props); + name = get_server_name(props); if ((res = init_socket_name(s, name)) < 0) goto error; @@ -1142,11 +1143,12 @@ static const struct pw_impl_module_events module_events = { static int need_server(struct pw_context *context, const struct spa_dict *props) { - const char *val; + const char *val = NULL; - val = getenv("PIPEWIRE_DAEMON"); - if (val == NULL) + if (props) val = spa_dict_lookup(props, PW_KEY_CORE_DAEMON); + if (val == NULL) + val = getenv("PIPEWIRE_DAEMON"); if (val && pw_properties_parse_bool(val)) return 1; return 0; diff --git a/src/modules/module-protocol-native/local-socket.c b/src/modules/module-protocol-native/local-socket.c index 9e87f85fb..bf80ecd1e 100644 --- a/src/modules/module-protocol-native/local-socket.c +++ b/src/modules/module-protocol-native/local-socket.c @@ -39,13 +39,14 @@ static const char * get_remote(const struct spa_dict *props) { - const char *name; + const char *name = NULL; - name = getenv("PIPEWIRE_REMOTE"); - if (props && name == NULL) + if (props) name = spa_dict_lookup(props, PW_KEY_REMOTE_NAME); if (name == NULL) - name = "pipewire-0"; + name = getenv("PIPEWIRE_REMOTE"); + if (name == NULL) + name = PW_DEFAULT_REMOTE; return name; } diff --git a/src/pipewire/core.h b/src/pipewire/core.h index f56e1c4ef..90afd3d6e 100644 --- a/src/pipewire/core.h +++ b/src/pipewire/core.h @@ -42,6 +42,9 @@ struct pw_core; #define PW_VERSION_REGISTRY 3 struct pw_registry; +/* the default remote name to connect to */ +#define PW_DEFAULT_REMOTE "pipewire-0" + /* default ID for the core object after connect */ #define PW_ID_CORE 0