conf: more work on config changes

Add -c option to pipewire to select config file. Use this to select
the uninstalled conf file.
Rename conf properties, prefix with context.
Simplify the main daemon now that everything can go in config.
Simplify pipewire-pulse now that we can put everything in config, it's
now virtually the same as pipewire but with a differenct config file.
Parse server addresses as array of strings.
This commit is contained in:
Wim Taymans 2021-02-11 21:01:58 +01:00
parent fc90a4e48a
commit 80825aeaea
16 changed files with 104 additions and 156 deletions

View file

@ -1,6 +1,6 @@
# Daemon config file for PipeWire RT clients version @VERSION@ #
# Real-time Client config file for PipeWire version @VERSION@ #
properties = {
context.properties = {
## Configure properties in the system.
#mem.warn-mlock = false
#mem.allow-mlock = true
@ -8,7 +8,7 @@ properties = {
#log.level = 2
}
spa-libs = {
context.spa-libs = {
## <factory-name regex> = <library-name>
#
# Used to find spa factory names. It maps an spa factory name
@ -19,7 +19,7 @@ spa-libs = {
support.* = support/libspa-support
}
modules = {
context.modules = {
## <module-name> = { [args = { <key>=<value> ... }]
# [flags = [ [ifexists] [nofail] ]}
#

View file

@ -1,6 +1,5 @@
# Daemon config file for PipeWire clients version @VERSION@ #
properties = {
# Client config file for PipeWire version @VERSION@ #
context.properties = {
## Configure properties in the system.
#mem.warn-mlock = false
#mem.allow-mlock = true
@ -8,7 +7,7 @@ properties = {
#log.level = 2
}
spa-libs = {
context.spa-libs = {
## <factory-name regex> = <library-name>
#
# Used to find spa factory names. It maps an spa factory name
@ -19,7 +18,7 @@ spa-libs = {
support.* = support/libspa-support
}
modules = {
context.modules = {
## <module-name> = { [args = { <key>=<value> ... }]
# [flags = [ [ifexists] [nofail] ]}
#

View file

@ -1,6 +1,6 @@
# Daemon config file for PipeWire JACK clients version @VERSION@ #
# JACK client config file for PipeWire version @VERSION@ #
properties = {
context.properties = {
## Configure properties in the system.
#mem.warn-mlock = false
#mem.allow-mlock = true
@ -8,7 +8,7 @@ properties = {
#log.level = 2
}
spa-libs = {
context.spa-libs = {
## <factory-name regex> = <library-name>
#
# Used to find spa factory names. It maps an spa factory name
@ -18,7 +18,7 @@ spa-libs = {
support.* = support/libspa-support
}
modules = {
context.modules = {
## <module-name> = { [args = { <key>=<value> ... }]
# [flags = [ [ifexists] [nofail] ]}
#

View file

@ -24,56 +24,39 @@
#include <signal.h>
#include <getopt.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/wait.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <pipewire/impl.h>
#include <pipewire/pipewire.h>
#include "config.h"
#define NAME "daemon"
#define DEFAULT_CONFIG_FILE "pipewire.conf"
struct data {
struct pw_context *context;
struct pw_main_loop *loop;
const char *daemon_name;
};
static const char *config_name = "pipewire.conf";
static void do_quit(void *data, int signal_number)
{
struct data *d = data;
pw_main_loop_quit(d->loop);
struct pw_main_loop *loop = data;
pw_main_loop_quit(loop);
}
static void show_help(struct data *d, const char *name)
static void show_help(const char *name)
{
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" --version Show version\n"
" -n, --name Daemon name (Default %s)\n",
" -c, --config Load config (Default %s)\n",
name,
d->daemon_name);
config_name);
}
int main(int argc, char *argv[])
{
struct data d;
struct pw_context *context;
struct pw_main_loop *loop;
struct pw_properties *properties;
static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "name", required_argument, NULL, 'n' },
{ "config", required_argument, NULL, 'c' },
{ NULL, 0, NULL, 0}
};
@ -82,19 +65,14 @@ int main(int argc, char *argv[])
if (setenv("PIPEWIRE_INTERNAL", "1", 1) < 0)
fprintf(stderr, "can't set PIPEWIRE_INTERNAL env: %m");
spa_zero(d);
pw_init(&argc, &argv);
d.daemon_name = getenv("PIPEWIRE_CORE");
if (d.daemon_name == NULL)
d.daemon_name = PW_DEFAULT_REMOTE;
while ((c = getopt_long(argc, argv, "hVn:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVc:", long_options, NULL)) != -1) {
switch (c) {
case 'h' :
show_help(&d, argv[0]);
case 'h':
show_help(argv[0]);
return 0;
case 'V' :
case 'V':
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",
@ -102,9 +80,8 @@ int main(int argc, char *argv[])
pw_get_headers_version(),
pw_get_library_version());
return 0;
case 'n' :
d.daemon_name = optarg;
fprintf(stdout, "set name %s\n", d.daemon_name);
case 'c':
config_name = optarg;
break;
default:
return -1;
@ -112,31 +89,30 @@ int main(int argc, char *argv[])
}
properties = pw_properties_new(
PW_KEY_CORE_NAME, d.daemon_name,
PW_KEY_CONFIG_NAME, "pipewire-uninstalled.conf",
PW_KEY_CORE_DAEMON, "true", NULL);
PW_KEY_CONFIG_NAME, config_name,
NULL);
d.loop = pw_main_loop_new(&properties->dict);
if (d.loop == NULL) {
loop = pw_main_loop_new(&properties->dict);
if (loop == NULL) {
pw_log_error("failed to create main-loop: %m");
return -1;
}
pw_loop_add_signal(pw_main_loop_get_loop(d.loop), SIGINT, do_quit, &d);
pw_loop_add_signal(pw_main_loop_get_loop(d.loop), SIGTERM, do_quit, &d);
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGINT, do_quit, loop);
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGTERM, do_quit, loop);
d.context = pw_context_new(pw_main_loop_get_loop(d.loop), properties, 0);
if (d.context == NULL) {
context = pw_context_new(pw_main_loop_get_loop(loop), properties, 0);
if (context == NULL) {
pw_log_error("failed to create context: %m");
return -1;
}
pw_log_info("start main loop");
pw_main_loop_run(d.loop);
pw_main_loop_run(loop);
pw_log_info("leave main loop");
pw_context_destroy(d.context);
pw_main_loop_destroy(d.loop);
pw_context_destroy(context);
pw_main_loop_destroy(loop);
pw_deinit();
return 0;

View file

@ -1,6 +1,5 @@
# Media session config file #
properties = {
context.properties = {
# Properties to configure the session and some
# modules.
#mem.mlock-all = false
@ -8,7 +7,7 @@ properties = {
#dbus = true
}
spa-libs = {
context.spa-libs = {
# Mapping from factory name to library.
api.bluez5.* = bluez5/libspa-bluez5
api.alsa.* = alsa/libspa-alsa
@ -16,7 +15,7 @@ spa-libs = {
api.libcamera.* = libcamera/libspa-libcamera
}
modules = {
context.modules = {
## <module-name> = { [args = { <key>=<value> ... }]
# [flags = [ [ifexists] [nofail] ]}
#

View file

@ -11,12 +11,15 @@ pipewire_c_args = [
conf_config = configuration_data()
conf_config.set('VERSION', '"@0@"'.format(pipewire_version))
conf_config.set('media_session_path', join_paths(pipewire_bindir, 'pipewire-media-session'))
conf_config.set('pipewire_path', join_paths(pipewire_bindir, 'pipewire'))
conf_config.set('pipewire_pulse_path', join_paths(pipewire_bindir, 'pipewire-pulse'))
conf_install_dir = join_paths(get_option('sysconfdir'), 'pipewire')
conf_config_uninstalled = conf_config
conf_config_uninstalled.set('media_session_path',
join_paths(meson.build_root(), 'src', 'examples', 'pipewire-media-session'))
conf_config_uninstalled.set('pipewire_path',
join_paths(meson.build_root(), 'src', 'daemon', 'pipewire'))
conf_config_uninstalled.set('pipewire_pulse_path',
join_paths(meson.build_root(), 'src', 'daemon', 'pipewire-pulse'))

View file

@ -27,11 +27,11 @@
#include <spa/utils/result.h>
#include <pipewire/impl.h>
#include <pipewire/pipewire.h>
#include "config.h"
static const char *address;
static const char *config_name = "pipewire-pulse.conf";
static void do_quit(void *data, int signal_number)
{
@ -45,11 +45,9 @@ static void show_help(const char *name)
"Start a pulseaudio compatible daemon.\n\n"
" -h, --help Show this help\n"
" --version Show version\n"
" -a --address comma separated list of addresses (Default %s)\n"
" unix:<socket-name>\n"
" tcp:[<ip>][:<port>]\n",
" -c, --config Load config (Default %s)\n",
name,
address);
config_name);
}
int main(int argc, char *argv[])
@ -57,20 +55,17 @@ int main(int argc, char *argv[])
struct pw_context *context;
struct pw_main_loop *loop;
struct pw_properties *properties;
char *args;
static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "address", required_argument, NULL, 'a' },
{ "config", required_argument, NULL, 'c' },
{ NULL, 0, NULL, 0}
};
int c;
pw_init(&argc, &argv);
address = "unix:native";
while ((c = getopt_long(argc, argv, "hVa:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVc:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
show_help(argv[0]);
@ -83,9 +78,8 @@ int main(int argc, char *argv[])
pw_get_headers_version(),
pw_get_library_version());
return 0;
case 'a':
address = optarg;
fprintf(stdout, "set address %s\n", address);
case 'c':
config_name = optarg;
break;
default:
return -1;
@ -93,7 +87,7 @@ int main(int argc, char *argv[])
}
properties = pw_properties_new(
PW_KEY_CONFIG_NAME, "pipewire-pulse.conf",
PW_KEY_CONFIG_NAME, config_name,
NULL);
loop = pw_main_loop_new(&properties->dict);
@ -111,19 +105,10 @@ int main(int argc, char *argv[])
return -1;
}
args = spa_aprintf("server.address=\"%s\"", address);
if (pw_context_load_module(context,
"libpipewire-module-protocol-pulse",
args, NULL) == NULL) {
pw_log_error("failed to create pulse module: %m");
return -1;
}
pw_log_info("start main loop");
pw_main_loop_run(loop);
pw_log_info("leave main loop");
free(args);
pw_context_destroy(context);
pw_main_loop_destroy(loop);
pw_deinit();

View file

@ -1,6 +1,5 @@
# Daemon config file for PipeWire pulse version @VERSION@ #
properties = {
# PulseAudio config file for PipeWire version @VERSION@ #
context.properties = {
## Configure properties in the system.
#mem.warn-mlock = false
#mem.allow-mlock = true
@ -8,49 +7,30 @@ properties = {
#log.level = 2
}
spa-libs = {
## <factory-name regex> = <library-name>
#
# Used to find spa factory names. It maps an spa factory name
# regular expression to a library name that should contain
# that factory.
#
context.spa-libs = {
audio.convert* = audioconvert/libspa-audioconvert
support.* = support/libspa-support
}
modules = {
## <module-name> = { [args = { <key>=<value> ... }]
# [flags = [ [ifexists] [nofail] ]}
#
# Loads a module with the given parameters.
# If ifexists is given, the module is ignored when it is not found.
# If nofail is given, module initialization failures are ignored.
#
# Uses RTKit to boost the data thread priority.
context.modules = {
libpipewire-module-rtkit = {
args = {
nice.level = -14
#nice.level = -11
#rt.prio = 20
#rt.time.soft = 200000
#rt.time.hard = 200000
}
flags = [ ifexists nofail ]
}
# The native communication protocol.
libpipewire-module-protocol-native = null
# Allows creating nodes that run in the context of the
# client. Is used by all clients that want to provide
# data to PipeWire.
libpipewire-module-client-node = null
# Makes a factory for wrapping nodes in an adapter with a
# converter and resampler.
libpipewire-module-adapter = null
# Allows applications to create metadata objects. It creates
# a factory for Metadata objects.
libpipewire-module-metadata = null
libpipewire-module-protocol-pulse = {
args = {
server.address = [
"unix:native"
# "tcp:4713"
}
}
}

View file

@ -1,6 +1,5 @@
# Daemon config file for PipeWire version @VERSION@ #
properties = {
context.properties = {
## Configure properties in the system.
#library.name.system = support/libspa-support
#context.data-loop.library.name.system = support/libspa-support
@ -11,6 +10,9 @@ properties = {
#mem.mlock-all = false
#log.level = 2
core.daemon = true # listening for socket connections
core.name = pipewire-0 # core name and socket name
## Properties for the DSP configuration.
#default.clock.rate = 48000
#default.clock.quantum = 1024
@ -22,7 +24,7 @@ properties = {
#default.video.rate.denom = 1
}
spa-libs = {
context.spa-libs = {
#<factory-name regex> = <library-name>
#
# Used to find spa factory names. It maps an spa factory name
@ -41,7 +43,7 @@ spa-libs = {
#audiotestsrc = audiotestsrc/libspa-audiotestsrc
}
modules = {
context.modules = {
#<module-name> = {
# [ args = { <key> = <value> ... } ]
# [ flags = [ [ ifexists ] [ nofail ] ]
@ -130,7 +132,7 @@ modules = {
libpipewire-module-session-manager = null
}
objects = {
context.objects = {
#<factory-name> = {
# [ args = { <key> = <value> ... } ]
# [ flags = [ [ nofail ] ]
@ -168,7 +170,7 @@ objects = {
#}
}
exec = {
context.exec = {
#<program-name> = { [ args = "<arguments>" ] }
#
# Execute the given program with arguments.
@ -183,5 +185,5 @@ exec = {
# It can be interesting to start another daemon here that listens
# on another address with the -a option (eg. -a tcp:4713).
#
#"@pipewire_pulse_path@" = { "#args" = "-a tcp:4713" }
#"@pipewire_path@" = { args = "-c pipewire-pulse.conf" }
}