site  contact  subhomenews

Pulseaudio support multiple users with TCP

November 04, 2021 — BarryK

I posted very early this morning how to support multiple users by using a Unix Domain Socket. Now considering an alternative, the TCP network protocol. Here is the previous blog post, using Unix Domain Socket:

https://bkhome.org/news/202111/disable-pulseaudio-idle-exit-and-support-multiple-users.html

It turns out that the TCP method is very simple. In /etc/pulse/default.pa, I loaded both Unix Domain socket and TCP:

load-module module-native-protocol-unix
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

The first one means there will be the usual socket /run/pulse/native, so apps like pavucontrol run happily.

The second one makes pulseaudio available anywhere in the local system, regardless of username or group. So, for example, /home/firefox/.config/pulse/client.conf:

default-server = 127.0.0.1

And for firefox running in a container, /mnt/wkg/containers/firefox/root/.config/pulse/client.conf:

default-server = 127.0.0.1

That's it, sound works for both of them.

The problem is, I don't know how to disable sound in a non-root client, or in a container. I really want to have individual control. For example, in the 'firefox' container, be able to enable or disable audio, without affecting other containers and non-root clients.

Documentation on pulseaudio modules is here:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#module-native-protocol-unixtcp    

Tags: easy