mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
core: always use explicitly configured properties first
First use the configured properties, then use the env variables. Make the daemon use the env variable by default. This makes it possible to start servers with PIPEWIRE_CORE env variable names but still override with the command option. Makes it possible to make apps connect to PIPEWIRE_REMOTE env by default and allows you to override with the command option.
This commit is contained in:
parent
bb20e0646c
commit
141238d88b
4 changed files with 23 additions and 15 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "daemon-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)
|
static void do_quit(void *data, int signal_number)
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +47,7 @@ static void show_help(const char *name)
|
||||||
" --version Show version\n"
|
" --version Show version\n"
|
||||||
" -n, --name Daemon name (Default %s)\n",
|
" -n, --name Daemon name (Default %s)\n",
|
||||||
name,
|
name,
|
||||||
daemon_name);
|
PW_DEFAULT_REMOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
@ -68,6 +68,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
|
daemon_name = getenv("PIPEWIRE_CORE");
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "hVn:", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "hVn:", long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h' :
|
case 'h' :
|
||||||
|
|
|
||||||
|
|
@ -978,15 +978,16 @@ static const struct spa_loop_control_hooks impl_hooks = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *
|
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)
|
||||||
if (props && name == NULL)
|
|
||||||
name = spa_dict_lookup(props, PW_KEY_CORE_NAME);
|
name = spa_dict_lookup(props, PW_KEY_CORE_NAME);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "pipewire-0";
|
name = getenv("PIPEWIRE_CORE");
|
||||||
|
if (name == NULL)
|
||||||
|
name = PW_DEFAULT_REMOTE;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1034,7 +1035,7 @@ impl_add_server(struct pw_protocol *protocol,
|
||||||
|
|
||||||
this = &s->this;
|
this = &s->this;
|
||||||
|
|
||||||
name = get_name(props);
|
name = get_server_name(props);
|
||||||
|
|
||||||
if ((res = init_socket_name(s, name)) < 0)
|
if ((res = init_socket_name(s, name)) < 0)
|
||||||
goto error;
|
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)
|
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 (props)
|
||||||
if (val == NULL)
|
|
||||||
val = spa_dict_lookup(props, PW_KEY_CORE_DAEMON);
|
val = spa_dict_lookup(props, PW_KEY_CORE_DAEMON);
|
||||||
|
if (val == NULL)
|
||||||
|
val = getenv("PIPEWIRE_DAEMON");
|
||||||
if (val && pw_properties_parse_bool(val))
|
if (val && pw_properties_parse_bool(val))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,14 @@
|
||||||
static const char *
|
static const char *
|
||||||
get_remote(const struct spa_dict *props)
|
get_remote(const struct spa_dict *props)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name = NULL;
|
||||||
|
|
||||||
name = getenv("PIPEWIRE_REMOTE");
|
if (props)
|
||||||
if (props && name == NULL)
|
|
||||||
name = spa_dict_lookup(props, PW_KEY_REMOTE_NAME);
|
name = spa_dict_lookup(props, PW_KEY_REMOTE_NAME);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "pipewire-0";
|
name = getenv("PIPEWIRE_REMOTE");
|
||||||
|
if (name == NULL)
|
||||||
|
name = PW_DEFAULT_REMOTE;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ struct pw_core;
|
||||||
#define PW_VERSION_REGISTRY 3
|
#define PW_VERSION_REGISTRY 3
|
||||||
struct pw_registry;
|
struct pw_registry;
|
||||||
|
|
||||||
|
/* the default remote name to connect to */
|
||||||
|
#define PW_DEFAULT_REMOTE "pipewire-0"
|
||||||
|
|
||||||
/* default ID for the core object after connect */
|
/* default ID for the core object after connect */
|
||||||
#define PW_ID_CORE 0
|
#define PW_ID_CORE 0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue