5

As in the title.

Is it possible without setting up a system-wide pulse server to mix audio output from multiple processes owned by different users on Linux? I have no trouble mixing audio when all the processes are owned by the same user, but as soon as I attempt using sound in processes owned by different users (specifically, mpd and the currently logged-in user's programs), it goes to first-come, first-served. Whichever user grabs the soundcard first gets access, and any other user's processes wait until it is released.

3 Answers 3

3

I managed to share an user-mode pulse server among local users via TCP.

Edit /etc/pulse/default.pa to enable the TCP module. I basically disabled auth to simplify configuration. Note there may be security implications if you aren't the only one using the computer.

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

Restart PulseAudio, if you are using systemd, this can be done with systemctl --user restart pulseaudio. Note that if there are already multiple PulseAudio servers running, you may need to stop them. Otherwise only the one that started first works.

Now PulseAudio should be listening on a TCP port, this can be verified with the command ss -ltp. You'll probably see something like this:

LISTEN     0    0        *:4713       *:*                    
users:(("pulseaudio",pid=3130,fd=31))

which indicates that PulseAudio is listening on the port 4713.

To configure clients, edit /etc/pulse/client.conf and enable auto connection:

auto-connect-localhost = yes

This is disabled by default on newer versions of PulseAudio for security reasons.

Next try playing some audio, cheers!

1
  • To load-module you can add also: listen=127.0.0.1
    – keypress
    Nov 7, 2019 at 10:18
2

put this on your ~/.pulse/default.pa of the current user running X

.include /etc/pulse/default.pa
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

Then restart pulseaudio with pulseaudio -k;pulseaudio -D

And then put this on all other users ~/.pulse/client.conf

default-server = 127.0.0.1

I initially learned about it at http://billauer.co.il/blog/2014/01/pa-multiple-users/, and tweaked it a bit (the include line)

working on ubuntu 20.04

mixed 2 musics from different users

1

For me on Debian 9 it was like this:

# add all your users to the audio group
usermod -aG audio user1
usermod -aG audio user2
usermod -aG audio user3

# pulseaudio config:    
# remove old per-user configs
rm -rf /home/*/.config/pulse/

# common client config
echo '
auto-connect-localhost = yes
' >> /etc/pulse/client.conf

# common server config - only the first one get started on login
echo '
load-module module-native-protocol-tcp listen=127.0.0.1 auth-ip-acl=127.0.0.1 auth-anonymous=1
' >> /etc/pulse/default.pa

Then restart, login, check:

ps aux | grep pulseaudio
# should be sth

netstat -ltunp | grep pulseaudio
# should be sth

# play sample file
cvlc 'https://file-examples.com/wp-content/uploads/2017/11/file_example_OOG_1MG.ogg'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .