module-protocol-native: use two-socket server by default

If no socket configuration specified for a server, create two sockets,
"CORENAME" and "CORENAME-manager" where CORENAME is the value computed
by get_server_name.
This commit is contained in:
Pauli Virtanen 2023-10-16 18:56:41 +03:00
parent 67c32ec3c2
commit 3d32291711
4 changed files with 23 additions and 7 deletions

View file

@ -105,7 +105,7 @@ context.modules = [
{ name = libpipewire-module-protocol-native { name = libpipewire-module-protocol-native
args = { args = {
# List of server Unix sockets, and optionally permissions # List of server Unix sockets, and optionally permissions
#sockets = [ { name = "pipewire-0" }, { name = "pipewire-manager-0" } ] #sockets = [ { name = "pipewire-0" }, { name = "pipewire-0-manager" } ]
} }
} }

View file

@ -1,9 +1,10 @@
[Unit] [Unit]
Description=PipeWire Multimedia System Socket Description=PipeWire Multimedia System Sockets
[Socket] [Socket]
Priority=6 Priority=6
ListenStream=%t/pipewire/pipewire-0 ListenStream=%t/pipewire/pipewire-0
ListenStream=%t/pipewire/pipewire-0-manager
SocketUser=pipewire SocketUser=pipewire
SocketGroup=pipewire SocketGroup=pipewire
SocketMode=0660 SocketMode=0660

View file

@ -1,9 +1,10 @@
[Unit] [Unit]
Description=PipeWire Multimedia System Socket Description=PipeWire Multimedia System Sockets
[Socket] [Socket]
Priority=6 Priority=6
ListenStream=%t/pipewire-0 ListenStream=%t/pipewire-0
ListenStream=%t/pipewire-0-manager
[Install] [Install]
WantedBy=sockets.target WantedBy=sockets.target

View file

@ -79,8 +79,10 @@ PW_LOG_TOPIC(mod_topic_connection, "conn." NAME);
* *
* Array of Unix socket names and (optionally) owner/permissions to serve, * Array of Unix socket names and (optionally) owner/permissions to serve,
* if the context is a server. If not absolute paths, the sockets are created * if the context is a server. If not absolute paths, the sockets are created
* in the default runtime directory. If not specified, one socket with * in the default runtime directory.
* a default name is created. *
* Has the default value `[ { name = "CORENAME" }, { name = "CORENAME-manager" } ]`,
* where `CORENAME` is the name of the PipeWire core, usually `pipewire-0`.
* *
* The permissions have no effect for sockets from Systemd socket activation. * The permissions have no effect for sockets from Systemd socket activation.
* Those should be configured via the systemd.socket(5) mechanism. * Those should be configured via the systemd.socket(5) mechanism.
@ -131,7 +133,7 @@ PW_LOG_TOPIC(mod_topic_connection, "conn." NAME);
*\code{.unparsed} *\code{.unparsed}
* context.modules = [ * context.modules = [
* { name = libpipewire-module-protocol-native, * { name = libpipewire-module-protocol-native,
* args = { sockets = [ { name = "pipewire-0" }, { name = "pipewire-1" } ] } } * args = { sockets = [ { name = "pipewire-0" }, { name = "pipewire-0-manager" } ] } }
* ] * ]
*\endcode *\endcode
*/ */
@ -1565,7 +1567,19 @@ static int create_servers(struct pw_protocol *this, struct pw_impl_core *core,
struct spa_json it[3]; struct spa_json it[3];
if (sockets == NULL) { if (sockets == NULL) {
if (add_server(this, core, &props->dict, NULL) == NULL) struct socket_info info = {0};
spa_autofree char *manager_name = NULL;
info.name = (char *)get_server_name(&props->dict);
if (add_server(this, core, &props->dict, &info) == NULL)
return -errno;
manager_name = spa_aprintf("%s-manager", info.name);
if (manager_name == NULL)
return -ENOMEM;
info.name = manager_name;
if (add_server(this, core, &props->dict, &info) == NULL)
return -errno; return -errno;
return 0; return 0;