Pulseaudio: Difference between revisions

From miki
Jump to navigation Jump to search
Line 16: Line 16:
pulseaudio -k
pulseaudio -k
</source>
</source>

{{note|Configuring pulseaudio to [https://wiki.ubuntu.com/PulseAudio/Log log in a file] does not work very well. Better use systemd journal.}}


== How-To ==
== How-To ==

Revision as of 12:18, 1 June 2020

This page contains dedicated information about Pulseaudio. See Linux audio page for more general information (might also include some general info on Pulseaudio).

References

Pulseaudio with systemd

On recent Ubuntu / Debian version, Pulseaudio is started by systemd.

  • Unit file is at /etc/systemd/user/default.target.wants/pulseaudio.service.
This file starts pulseaudio in non-daemon mode.
  • To get pulseaudio log, do something like journalctl | grep pulseaudio.
  • To restart pulseaudio, simply kill it. For instance:
pulseaudio -k
 ✐  Configuring pulseaudio to log in a file does not work very well. Better use systemd journal.

How-To

PulseAudio in multi-user (relay)

The solution is to have all users have their own PulseAudio server, but all of these relay to one server (typically the one of current active user, see [1]).

For each potential active user, edit file ~/.pulse/default.pa:

.include /etc/pulse/default.pa

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

For all users that needs to relay to active user, edit file ~/.pulse/client.conf:

default-server = 127.0.0.1

Active user might also need to run:

xhost +

PulseAudio in multi-user (system mode)

Main article: [2] (see also [3])

CAUTION — PulseAudio developers seriously recommend against this (see [4])

The solution here is to run pulseaudio as a system-wide daemon. For this:

  • Enable system start. For 12.04, edit /etc/default/pulseaudio:
PULSEAUDIO_SYSTEM_START=1

For 12.10, edit /etc/init/pulseaudio.conf:

start on runlevel [2345]
  • Edit /etc/pulse/daemon.conf — See man pulse-daemon.conf for more information.
daemonize = yes
local-server-type = system
  • Edit /etc/pulse/client.conf (this is actually not really necessary
autospawn = no

We also need to add users to the pulse-access group.

sudo usermod -a -G pulse-access <username>

Troubleshooting

General

Troubleshooting PulseAudio:

paplay /usr/share/sounds/alsa/Front_Center.wav           # Try to play using PulseAudio

Choppy sound in flash video

Reference askubuntu.

  • Simply kill and restart pulseaudio:
pulseaudio -k
pusseaudio -D       # To restart it - not needed if pulse runs in daemon mode

Understanding / Troubleshooting PulseAudio

  • Only active user has access to /dev/snd/* devices. Access is granted by ConsoleKit when user logs in [5]. Access control can be seen with
getfacl /dev/snd/*
  • To restart PulseAudio [6]
pulseaudio --check && echo running       # Check if any pulseaudio is running
pulseaudio -k                            # ... if so, kill it
pulseaudio -D                            # and start it again (optional is auto-spawn is enabled)