main: assemble the full config file name and pass that to pipewire

Previously we had the config file split in pipewire-fashion: CONFIG_NAME for
the filename and CONFIG_PREFIX for the (absolute) config directory the file
resides in. Since we always resolved CONFIG_PREFIX to be an absolute path we
might as well just pass the fully resolved config file to pipewire instead.

This will eventually allow us to have multiple lookup directories.
This commit is contained in:
Peter Hutterer 2021-07-07 14:30:21 +10:00 committed by George Kiagiadakis
parent 2461654017
commit 6c3a8d2f83

View file

@ -327,6 +327,22 @@ init_done (WpCore * core, GAsyncResult * res, WpDaemon * d)
}
}
static gchar *
find_config (const gchar *config_file_name)
{
g_autofree gchar *path = NULL;
if (!config_file_name)
config_file_name = "wireplumber.conf";
if (g_path_is_absolute (config_file_name))
path = g_strdup (config_file_name);
else
path = g_build_filename (wp_get_config_dir (), config_file_name, NULL);
return g_canonicalize_filename (path, NULL);
}
gint
main (gint argc, gchar **argv)
{
@ -334,6 +350,7 @@ main (gint argc, gchar **argv)
g_autoptr (GOptionContext) context = NULL;
g_autoptr (GError) error = NULL;
g_autoptr (WpProperties) properties = NULL;
g_autofree gchar *config_file_path = NULL;
wp_init (WP_INIT_ALL);
@ -344,22 +361,15 @@ main (gint argc, gchar **argv)
return WP_EXIT_USAGE;
}
config_file_path = find_config (config_file);
properties = wp_properties_new (
PW_KEY_CONFIG_NAME, config_file ? config_file : "wireplumber.conf",
PW_KEY_CONFIG_NAME, config_file_path,
PW_KEY_APP_NAME, "WirePlumber",
"wireplumber.daemon", "true",
"wireplumber.export-core", "true",
NULL);
if (!g_path_is_absolute (wp_get_config_dir ())) {
g_autofree gchar *cwd = g_get_current_dir ();
g_autofree gchar *conf_dir =
g_build_filename (cwd, wp_get_config_dir (), NULL);
wp_properties_set (properties, PW_KEY_CONFIG_PREFIX, conf_dir);
} else {
wp_properties_set (properties, PW_KEY_CONFIG_PREFIX, wp_get_config_dir ());
}
/* init wireplumber daemon */
d.loop = g_main_loop_new (NULL, FALSE);
d.core = wp_core_new (NULL, g_steal_pointer (&properties));