Difference between revisions of "PulseAudio"

From ArchWiki
Jump to: navigation, search
(Modify PulseAudio's configuration file (3/4): transposed numbers, check link in section for reference)
(daemon.conf: Copied descriptions of some missing options from https://wiki.archlinux.org/index.php?title=PulseAudio/Configuration&oldid=322119 – I find them useful, but they may require some cleanup.)
 
(336 intermediate revisions by 97 users not shown)
Line 1: Line 1:
[[Category:Audio/Video]]
 
 
[[Category:Sound]]
 
[[Category:Sound]]
 
[[cs:PulseAudio]]
 
[[cs:PulseAudio]]
Line 8: Line 7:
 
[[pt:PulseAudio]]
 
[[pt:PulseAudio]]
 
[[ru:PulseAudio]]
 
[[ru:PulseAudio]]
[[tr:PulseAudio]]
+
[[zh-hans:PulseAudio]]
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|PulseAudio/Examples}}
 
{{Related|PulseAudio/Examples}}
 +
{{Related|PulseAudio/Troubleshooting}}
 
{{Related articles end}}
 
{{Related articles end}}
[[Wikipedia:PulseAudio|PulseAudio]] is a sound server commonly used by desktop environments like [[GNOME]] or [[KDE]]. It serves as a proxy to sound applications using existing kernel sound components like [[ALSA]] or [[OSS]]. Since [[ALSA]] is included in Arch Linux by default, the most common deployment scenarios include PulseAudio with [[ALSA]].
+
[[Wikipedia:PulseAudio|PulseAudio]] PulseAudio is a general purpose sound server intended to run as a middleware between your applications and your hardware devices, either using [[ALSA]] or [[OSS]]. It also offers easy network streaming accross local devices using [[Avahi]] if enabled. While its main purpose is to ease audio configuration, its modular design allows more advanced users to configure the daemon precisely to best suit their needs.
 +
 
 +
{{Note|Some confusion may occur between [[ALSA]] and PulseAudio. ALSA includes a Linux kernel component with sound card drivers, as well as a userspace component, {{ic|libalsa}}.[http://www.alsa-project.org/main/index.php/Download] PulseAudio builds only on the kernel component, but offers compatibility with {{ic|libalsa}} through {{Pkg|pulseaudio-alsa}}.[http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/#index14h3]}}
  
 
== Installation ==
 
== Installation ==
* Required package:  {{Pkg|pulseaudio}}
 
* Optional GTK GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}
 
* Optional volume control via mapped keyboard keys: {{AUR|pulseaudio-ctl}}
 
* Optional console (CLI) mixers: {{Pkg|ponymix}} and {{AUR|pamixer-git}}
 
* Optional web volume control: [https://github.com/Siot/PaWebControl PaWebControl]
 
* Optional system tray icon: {{AUR|pasystray-git}}
 
* Optional KDE plasma applet: {{Pkg|kdemultimedia-kmix}} and {{AUR|kdeplasma-applets-veromix}}
 
  
== Running ==
+
[[Install]] the {{Pkg|pulseaudio}} package.
{{Warning|If you have per-user copies of configuration files (such as {{ic|client.conf}}, {{ic|daemon.conf}} or {{ic|default.pa}}) in {{ic|~/.config/pulse/}} or {{ic|~/.pulse/}}, make sure you keep them in sync with changes to the packaged files in {{ic|/etc/pulse/}}. Otherwise, PulseAudio may refuse to start due to configuration errors.}}
 
  
{{Note|Most X11 environments start PulseAudio automatically with the X11 session.}}
+
{{Note|Some PulseAudio modules have been [https://www.archlinux.org/news/pulseaudio-split/ split] from the main package and must be installed separately if needed.}}
  
In the unlikely event that PulseAudio is not automatically started upon entering X, it can can be started with:
+
* For PulseAudio to manage [[ALSA]] as well, install  the {{Pkg|pulseaudio-alsa}} package, see [[#ALSA]].
$ pulseaudio --start
+
* For [[bluetooth]] support (Bluez), install the {{Pkg|pulseaudio-bluetooth}} package, see [[bluetooth headset]] page.
 +
* For equalizer sink (qpaeq), install the {{Pkg|pulseaudio-equalizer}} package.
 +
* For GConf support (paprefs), install the {{Pkg|pulseaudio-gconf}} package.
 +
* For [[JACK]] sink, source and jackdbus detection, install the {{Pkg|pulseaudio-jack}} package.
 +
* For infrared (LIRC) volume control, install the {{Pkg|pulseaudio-lirc}} package.
 +
* For Zeroconf ([[Avahi]]/DNS-SD) support, install the {{Pkg|pulseaudio-zeroconf}} package.
  
PulseAudio can be stopped with:
+
=== Front-ends ===
$ pulseaudio -k
 
  
== Equalizer ==
+
{{Style|Application lists should use [[Template:App]].}}
Newer PulseAudio versions have an integrated 10-band equalizer system. In order to use the equalizer do the following:
 
  
=== Load equalizer sink and dbus-protocol module ===
+
There are a number of front-ends available for controlling the PulseAudio daemon:
$ pactl load-module module-equalizer-sink
 
$ pactl load-module module-dbus-protocol
 
  
=== Install and run the GUI front-end ===
+
* For graphical configuration/volume control, install the {{Pkg|pavucontrol}} or {{Pkg|pavucontrol-qt}} package.
Install {{Pkg|python-pyqt4}} and execute:
+
* For graphical general daemon configuration, install the {{Pkg|paprefs}} package.
 +
* For console (CLI) mixers, install the {{Pkg|ponymix}} or {{Pkg|pamixer}} package.
 +
* For console (curses) mixer, install the {{AUR|pulsemixer}} package.
 +
* For volume control via mapped keyboard keys, install the {{AUR|pulseaudio-ctl}}, {{AUR|pavolume-git}} package.
 +
* For system tray icon, install the {{AUR|pasystray}}, {{AUR|pasystray-git}} or {{AUR|pasystray-gtk2-standalone}} package.
 +
: {{Tip|The non-standalone versions of {{ic|pasystray}} can install both GTK2 and GTK3 versions and requires choosing which during build. The standalone versions install a single version.}}
 +
* For [[KDE]] Framework 5 Plasma applet, install the {{Pkg|kmix}} and {{Pkg|plasma-pa}} package.
 +
* For [[Xfce]] 4 plugin: {{Pkg|xfce4-pulseaudio-plugin}}, {{AUR|pa-applet-git}} package.
 +
* For web volume control, see [https://github.com/Siot/PaWebControl PaWebControl].
  
$ qpaeq
+
== Configuration ==
 +
{{Merge|PulseAudio/Configuration|Configuration should stay in the main article, so the linked page should be merged here.|section=Abandoned draft}}
  
{{Note|If qpaeq has no effect, install {{pkg|pavucontrol}} and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}
+
By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirects all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks.  
  
=== Load equalizer and dbus module on every boot ===
+
While PulseAudio usually runs fine out of the box and requires only minimal configuration, advanced users can change almost every aspect of the daemon by either altering the default configuration file to disable modules or writing your own from scratch.
Edit the file {{ic|/etc/pulse/default.pa}} with your favorite editor and append the following lines:
 
  
### Load the integrated PulseAudio equalizer and D-Bus module
+
PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its '''modules''' except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules, including PulseAudio's native protocol itself (provided by [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index22h3 module-native-protocol-unix]). Clients reach the server through one of many protocol modules that will accept audio from external sources, route it through PulseAudio and eventually have it go out through a final other module. The output module does not have to be an actual sound output: it can dump the stream into a file, stream it to a broadcasting server such as [[Icecast]], or even just discard it.
load-module module-equalizer-sink
 
load-module module-dbus-protocol
 
  
== Back-end configuration ==
+
You can find a detailed list of all available modules at [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/ Pulseaudio Loadable Modules]. To enable them you can just add a line {{ic|load-module <module-name-from-list>}} to {{ic|~/.config/pulse/default.pa}}.
=== ALSA ===
 
* Recommended package: {{Pkg|pulseaudio-alsa}}
 
* Optional packages: {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}}
 
  
{{Note|Optional packages are needed only if running x86_64 and wanting to have sound for 32-bit programs (like Wine).}}
+
=== Configuration files ===
  
For the applications that do not support PulseAudio and support ALSA it is '''recommended''' to install the PulseAudio plugin for ALSA. This package also contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio.
+
PulseAudio will first look for configuration files in the home directory {{ic|~/.config/pulse}}, then system-wide {{ic|/etc/pulse}}.
  
To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not being loaded at boot. If it is currently loaded ({{ic|<nowiki>lsmod | grep oss</nowiki>}}), disable it by executing:
+
{{Tip|
# rmmod snd_pcm_oss
+
* It is strongly suggested not to edit system-wide configuration files, but rather edit user ones. Create the {{ic|~/.config/pulse}} directory, then copy the system configuration files into it and edit according to your need.
 +
* Make sure you keep user configuration in sync with changes to the packaged files in {{ic|/etc/pulse/}}. Otherwise, PulseAudio may refuse to start due to configuration errors.
 +
* There is usually no need to add your user to the {{ic|audio}} group, as PulseAudio uses [[udev]] and ''logind'' to give access dynamically to the currently "active" user. Exceptions would include running the machine headless so that there is no currently "active" user.}}
  
=== ALSA/dmix without grabbing hardware device ===
+
==== daemon.conf ====
{{Note|This section describes alternative configuration, which is generally '''not''' recommended.}}
 
  
You may want to use ALSA directly in most of your applications and to be able to use other applications, which constantly require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.
+
This is the main configuration file to configure the daemon itself. It defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. The defaults are sensible for most users, see the {{man|5|pulse-daemon.conf}} manpage for additional information. Boolean options accepts any of these: {{ic|true}}, {{ic|yes}}, {{ic|on}} and {{ic|1}} as well as {{ic|false}}, {{ic|no}}, {{ic|off}} and {{ic|0}}.
  
* Remove package {{Pkg|pulseaudio-alsa}}, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
+
{{Note|PulseAudio does not perform tilde expansion on paths in this file. Use absolute paths for any files.}}
  
* Edit {{ic|/etc/pulse/default.pa}}.
+
{| class="wikitable"
:Find and uncomment lines which load back-end drivers. Add '''device''' parameters as follows. Then find and comment lines which load autodetect modules.
+
|+ Notable configuration options
load-module module-alsa-sink '''device=dmix'''
+
! Option || Description
load-module module-alsa-source '''device=dsnoop'''
+
|+
# load-module module-udev-detect
+
| daemonize || Controls whether the server will daemonize itself and return. Set to {{ic|no}} when debugging so you can see the debugging information on the terminal.
# load-module module-detect
+
|+
 +
| resample-method || Which resampler to use when audio with incompatible sample rates needs to be passed between modules (e.g. playback of 96kHz audio on hardware which only supports 48kHz). The available resamplers can be listed with {{ic|$ pulseaudio --dump-resample-methods}}. Choose the best tradeoff between CPU usage and audio quality for the present use-case. {{Tip|In some cases PulseAudio will generate a high CPU load. This can happen when multiple streams are resampled (individually). If this is a common use-case in a workflow, it should be considered to create an additional sink at a matching sample rate which can then be fed into the main sink, resampling only once.}}
 +
|+
 +
| avoid-resampling || With {{ic|1=avoid-resampling = yes}}, PulseAudio automatically configures the hardware to the sample rate which the application uses, if the hardware supports this sample rate (needs [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/ PA 11] or higher)
 +
{{Warning|Enabling this feature might cause audio distortion, therefore it is disabled by default, see the [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/ release notes] for more information.}}
 +
|+
 +
| enable-remixing || When the input and output have a different channel count (for example, outputting a 6 channel movie into a stereo sink), pulse can either remix all the channels (default, {{ic|yes}}) or just trivially map the channels by their name (left goes to left, right to right, all others ignored) when {{ic|no}}
 +
|+
 +
| system-instance || If set to {{ic|yes}}, run the daemon as a [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/ system-wide] instance. [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ Highly discouraged] as it can introduce security issues. Useful on [[Xorg multiseat|Multiseat]] systems, or headless systems that have no real local users. Defaults to {{ic|no}}.
 +
|+
 +
| flat-volumes ||{{ic|flat-volumes}} scales the device-volume with the volume of the "loudest" application. For example, raising the VoIP call volume will raise the hardware volume and adjust the music-player volume so it stays where it was, without having to lower the volume of the music-player manually. Defaults to {{ic|yes}} upstream, but to {{ic|no}} within Arch. {{Note|The default behavior upstream can sometimes be confusing and some applications, unaware of this feature, can set their volume to 100% at startup, potentially blowing your speakers or your ears. This is why Arch defaults to the classic (ALSA) behavior by setting this to {{ic|no}}.}}
 +
|+
 +
| realtime-scheduling || If your kernel supports realtime scheduling (for instance, [[Kernels#-rt]]{{Broken section link}} or [[Kernels#-ck]]{{Broken section link}}), set this to {{ic|yes}} to ensure PulseAudio can deliver low-latency glitch-free playback. You can adjust {{ic|realtime-priority}} as well to have it use the correct priority, especially when [[JACK]] is also running on the system.
 +
|+
 +
| nice-level || Since PulseAudio runs in userspace and involves inter-process communication, audio can be subject to dropouts if the daemon doesn't have enough CPU time to process the audio. The default usually is enough, but can be tweaked to give pulse the wanted priority over (or below) other applications.
 +
|+
 +
| exit-idle-time || If you want to run PulseAudio only when needed and use ALSA otherwise, you can set a delay in seconds after which the daemon will automatically shutdown after all clients are disconnected. Set it to -1 to disable this feature.
 +
|+
 +
| log-level || When debugging, you may want to increase the logging level of the daemon to see exactly why a specific module fails to load. High logging levels will sometimes print useful information such as detected minimum latency for the system, which can then be used to tweak {{ic|default-fragments}} and {{ic|default-fragment-size-msec}}.
 +
|+
 +
| default-sample-format || Usually doesn't need change, but if your sound card's native format is diffent performance and quality can be improved by setting the right format here.
 +
|+
 +
| default-sample-rate || The default sample rate user by pulse unless overriden at module level. Change this if your sound card doesn't support 44100Hz or if you wish to upsample all audio. See previous note about CPU usage.
 +
|+
 +
| alternate-sample-rate || To fix a common limitation where movies at 48000Hz were needlessly downsampled to 44100Hz, some modules support changing their sample rate dynamically to avoid resampling when possible. See manual for more in-depth information. Usually don't need any change.
 +
|+
 +
| default-channels || The default number of channels when not specified. Usually don't need any change as you can configure more channels on per-module basis.
 +
|+
 +
| default-fragments || Audio samples are split into multiple fragments of {{ic|default-fragment-size-msec}} each. The larger the buffer is, the less likely audio will skip when the system is overloaded. On the downside this will increase the overall latency. Increase this value if you have issues.
 +
|+
 +
| default-fragment-size-msec || The size in milliseconds of each fragment. This is the amount of data that will be processed at once by the daemon. TODO: Verify
 +
|}
  
* ''Optional:'' If you use {{Pkg|kdemultimedia-kmix}} you may want to control ALSA volume instead of PulseAudio volume:
+
==== default.pa ====
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
 
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
 
  
* Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
+
This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additional commands can be sent at runtime using {{ic|$ pactl}} or {{ic|$ pacmd}}. The startup script can also be provided on the command line by starting PulseAudio in a terminal using {{ic|$ pulseaudio -nC}}. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self-explanatory, consult {{man|5|pulse-cli-syntax}} for the details of the syntax.
:Use {{Pkg|pavucontrol}} to control PulseAudio volume if needed.
 
  
=== OSS ===
+
{{tip|
There are multiple ways of making OSS-only programs play to PulseAudio:
+
* Rather than being a complete copy, {{ic|~/.config/pulse/default.pa}} can start with the line {{ic|.include /etc/pulse/default.pa}} and then just override the defaults.
 +
* Run {{ic|<nowiki>$ pacmd list-sinks|egrep -i 'index:|name:'</nowiki>}} to list available sinks. The present default sink is marked with an asterisk.
 +
* Edit {{ic|~/.config/pulse/default.pa}} to insert/alter the set-default-sink command using the sink's name as the numbering cannot be guaranteed repeatable.
 +
}}
  
==== ossp ====
+
==== client.conf ====
Install {{Pkg|ossp}} package and start '''osspd''' service.
+
This is the configuration file read by every PulseAudio client application. It is used to configure runtime options for individual clients. It can be used to set and configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.
  
==== padsp wrapper (part of PulseAudio) ====
+
=== Configuration command ===
Programs using OSS can work with PulseAudio by starting it with padsp:
 
  
$ padsp OSSprogram
+
The main command to configure a server during runtime is {{ic|$ pacmd}}. Run {{ic|$ pacmd --help}} for a list options, or just run {{ic|$ pacmd}} to enter the shell interactive mode and {{ic|Ctrl+d}} to exit. All modifications will immediately be applied.
A few examples:
 
$ padsp aumix
 
$ padsp sox foo.wav -t ossdsp /dev/dsp
 
  
You can also add a custom wrapper script like this: 
+
Once your new settings have been tested and meet your needs, edit the {{ic|default.pa}} accordingly to make the change persistent. See [[PulseAudio/Examples]] for some basic settings.
{{hc|/usr/local/bin/OSSProgram|<nowiki>
 
#!/bin/sh
 
exec padsp /usr/bin/OSSprogram "$@"
 
</nowiki>}}
 
Make sure {{ic|/usr/local/bin}} comes before {{ic|/usr/bin}} in your '''PATH'''.
 
  
=== GStreamer ===
+
{{Tip|leave the {{ic|load-module module-default-device-restore}} line in the {{ic|default.pa}} file untouched. It will allow you to restart the server in its default state, thus dismissing any wrong setting.}}
To make [[GStreamer]] use PulseAudio, you need to install {{Pkg|gst-plugins-good}} or {{Pkg|gstreamer0.10-good-plugins}}.
 
  
=== OpenAL ===
+
It is important to understand that the "sources" (processes, capture devices) and "sinks" (sound cards, servers, other processes) accessible and selectable through PulseAudio depend upon the current hardware "Profile" selected.  These "Profiles" are those ALSA "pcms" listed by the command {{ic|aplay -L}}, and more specifically by the command {{ic|pacmd list-cards}}, which will include a line "index:", a list beginning "profiles:", and a line "active profile: <...>" in the output, among other things. "Profiles" correspond to different card input/output configurations, notably the number of available input/output channels.
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}
 
  
=== libao ===
+
The "active profile"  can be set with the command {{ic|pacmd set-card-profile INDEX PROFILE}}, with ''no'' comma separating INDEX and PROFILE, where INDEX is just the number on the line "index:" and a PROFILE name is everything shown from the beginning of any line under "profile:" to just ''before'' the colon and first space, as shown by the command {{ic|pacmd list-cards}}.  For instance, {{ic|pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo}}.
Edit the libao configuration file:
 
{{hc|# /etc/libao.conf|2=default_driver=pulse}}
 
Be sure to remove the {{ic|1=dev=default}} option of the alsa driver or adjust it to specify a specific Pulse sink name or number.  
 
  
{{Note|You could possibly also keep the libao standard of outputting to the ''alsa'' driver and its default device if you install {{pkg|pulseaudio-alsa}} since the ALSA default device then '''is''' PulseAudio.}}
+
It may be easier to select a "Profile" with a graphical tool like {{ic|pavucontrol}}, under the "Configuration" tab, or KDE System Settings, "Multimedia/Audio and Video Settings", under the "Audio Hardware Setup" tab.  Each audio "Card", which are those devices listed by the command {{ic|aplay -l}}, or again by the command {{ic|pacmd list-cards}}, will have its own selectable "Profile".  When a "Profile" has been selected, the then available "sources" and "sinks" can be seen by using the commands {{ic|pacmd list-sources}} and {{ic|pacmd list-sinks}}.  Note that the "index" of the available sources and sinks will change each time a card profile is changed.
  
=== ESD ===
+
The selected "Profile" can be an issue for some applications, especially the Adobe Flash players, typically {{ic|/usr/lib/mozilla/plugins/libflashplayer.so}} and {{ic|/usr/lib/PepperFlash/libpepflashplayer.so}}.  Often, these Flash players will only work when one of the Stereo profiles is selected, and otherwise, will play video with no sound, or will simply "crash". When all else fails, you might try selecting a different profile.
PulseAudio is a drop-in replacement for the enlightened sound daemon (ESD). While PulseAudio is running, ESD clients should be able to output to it without configuration.
 
  
== Desktop environments ==
+
Of course, when configuring some variation of Surround Sound in PulseAudio, the appropriate Surround profile will have to be selected, before Surround Sound will work, or in order to do things like remap the speaker channels.
=== General X11 ===
 
{{Note|As mentioned previously, PulseAudio is very likely launched automatically via either {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}} or the files in {{ic|/etc/xdg/autostart/}} if users have some DE installed.}}
 
  
Check to see if PulseAudio is running:
+
== Running ==
 
 
{{hc|<nowiki>$ ps aux | grep pulse</nowiki>|
 
facade  1794  0.0  0.0 360464  6532 ?        S<l  15:33  0:00 /usr/bin/pulseaudio --start
 
facade  1827  0.0  0.0  68888  2608 ?        S    15:33  0:00 /usr/lib/pulse/gconf-helper
 
}}
 
  
If PulseAudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins manually:
+
PulseAudio on Arch has {{ic|pulseaudio.socket}} enabled by default for the [[systemd/User]] instance. This means that PulseAudio will automatically start when needed.
$ start-pulseaudio-x11
 
  
If you are not running GNOME, KDE, or Xfce, and your {{ic|~/.xinitrc}} does not source the scripts in {{ic|/etc/X11/xinit/xinitrc.d}} (such as is done in the example file {{ic|/etc/skel/.xinitrc}}), then you can launch PulseAudio on boot with:
+
{{Note|
{{hc|~/.xinitrc|
+
* To disable {{ic|pulseaudio.socket}}, make sure that {{ic|$XDG_CONFIG_HOME/systemd/user/}} exists and run {{ic|systemctl --user mask pulseaudio.socket}}.
/usr/bin/start-pulseaudio-x11
+
* Many [[desktop environments]] autostart programs based on [[Desktop entries#Autostart|desktop files]] in the {{ic|/etc/xdg/autostart/}} directory. In this case, PulseAudio will be launched automatically regardless of the socket activation status.
 
}}
 
}}
  
=== GNOME ===
+
For more information, see [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Running/ PulseAudio: Running].
As of GNOME 3, GNOME fully integrates with PulseAudio and no extra configuration is needed.
 
  
=== KDE Plasma Workspaces and Qt4 ===
+
== Back-end configuration ==
PulseAudio, it will be used by KDE/Qt4 applications. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE page in the PulseAudio wiki].
 
  
PulseAudio support has been merged into KMix, the default KDE sound mixer.
+
=== ALSA ===
  
If the phonon-gstreamer backend is used for Phonon, GStreamer should also be [[PulseAudio#GStreamer|configured]] to use PulseAudio by installing {{Pkg|gstreamer0.10-good-plugins}}.
+
If you have applications that do not support PulseAudio explicitly but rely on ALSA, these applications will try to access the sound card directly via ALSA and will therefore bypass PulseAudio. PulseAudio will thus not have access to the sound card any more. As a result, all applications relying on PulseAudio will not be working any more, leading to [[PulseAudio/Troubleshooting#The only device shown is "dummy output" or newly connected cards are not detected|this issue]]. To prevent this, you will need to install the {{Pkg|pulseaudio-alsa}} package. It contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio. Also make sure that {{ic|~/.asoundrc}} does not exist, as it would override the {{ic|/etc/asound.conf}} file.
  
One useful tidbit from that page is to add {{ic|load-module module-device-manager}} to {{ic|/etc/pulse/default.pa}}.
+
Please also install {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}} if you run a x86_64 system and want to have sound for 32-bit [[multilib]] programs like [[Wine]] and [[Steam]].
  
Additionally, the {{AUR|kdeplasma-applets-veromix}} is available in the [[AUR]] as a KDE alternative to KMix or pavucontrol.
+
To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not being loaded at boot. If it is currently loaded ({{ic|<nowiki>lsmod | grep oss</nowiki>}}), disable it by executing:
 +
# rmmod snd_pcm_oss
  
If KMix/Veromix fail to connect to PulseAudio at boot you may need to edit {{ic|/etc/pulse/client.conf}} to include  {{ic|autospawn &#61; yes}} instead of {{ic|autospawn &#61; no}}.
+
==== Expose PulseAudio sources, sinks and mixers to ALSA ====
 +
Although {{Pkg|pulseaudio-alsa}} contains the necessary configuration file to allow ALSA applications to use PulseAudio's default device, ALSA's {{ic|pulse}} plugin is more versatile than that:
  
=== Xfce ===
+
{{hc|~/.asoundrc (or /etc/asound.conf)|2=
Applications running under Xfce can take advantage of PulseAudio. To manage PulseAudio settings, you can use {{Pkg|pavucontrol}}.
+
# Create an alsa input/output using specific PulseAudio sources/sinks
 +
pcm.pulse-example1 {
 +
    type pulse
 +
    device "my-combined-sink" # name of a source or sink
 +
    fallback "pulse-example2" # if combined not available
 +
}
 +
 +
pcm.pulse-example2 {
 +
    type pulse
 +
    device "other-sound-card" # name of a source or sink
 +
    # example: device "alsa_output.pci-0000_00_1b.0.analog-stereo"
 +
}
 +
 +
# Create an alsa mixer using specific PulseAudio sources/sinks
 +
# these can be tested with "alsamixer -D pulse-example3"
 +
ctl.pulse-example3 {
 +
    type pulse
 +
    device "my-output" # name of source or sink to control
 +
 +
    # example: always control the laptop speakers:
 +
    # device "alsa_output.pci-0000_00_1b.0.analog-stereo"
 +
    fallback "pulse-example4" # supports fallback too
 +
}
 +
 +
# Mixers also can control a specific source and sink, separately:
 +
ctl.pulse-example4 {
 +
    type pulse
 +
    sink "my-usb-headphones"
 +
    source "my-internal-mic"
 +
   
 +
    # example: output to HDMI, record using internal
 +
    sink "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
 +
    source "alsa_input.pci-0000_00_1b.0.analog-stereo"
 +
}
 +
 +
# These can override the default mixer (example: for pnmixer integration)
 +
ctl.!default {
 +
    type pulse
 +
    sink "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
 +
    source "alsa_input.pci-0000_00_1b.0.analog-stereo"
 +
}
 +
}}
  
== Applications ==
+
The [http://git.alsa-project.org/?p=alsa-plugins.git;a=tree;f=pulse;hb=HEAD source code] can be read to know all available options.
=== Audacious ===
 
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.
 
  
=== Java/OpenJDK 6 ===
+
==== ALSA/dmix without grabbing hardware device ====
Create a wrapper for the Java executable using padsp as seen on the [[Java#Java_sound_with_PulseAudio|Java sound with PulseAudio]] page.
 
  
=== Music Player Daemon (MPD) ===
+
{{Note|This section describes alternative configuration, which is generally '''not''' recommended.}}
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio. See also [[MPD/Tips and Tricks#MPD and PulseAudio]].
 
  
=== MPlayer ===
+
You may want to use ALSA directly in most of your applications while still being able to use applications which require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.
[[MPlayer]] natively supports PulseAudio output with the {{ic|-ao pulse}} option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:
 
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}
 
  
=== Skype (x86_64 only) ===
+
* Remove package {{Pkg|pulseaudio-alsa}}, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
Install {{Pkg|lib32-libpulse}}, otherwise the following error will occur when trying to initiate a call: "Problem with Audio Playback".
 
  
== Troubleshooting ==
+
* Edit {{ic|/etc/pulse/default.pa}}.
=== No sound after install ===
+
:Find and uncomment lines which load back-end drivers. Add '''device''' parameters as follows. Then find and comment lines which load autodetect modules.
==== Muted audio device ====
+
load-module module-alsa-sink '''device=dmix'''
If one experiences no audio output via any means while using ALSA, attempt to unmute the sound card. To do this, launch {{ic|alsamixer}} and make sure each column has a green 00 under it (this can be toggled by pressing {{ic|m}}):
+
load-module module-alsa-source '''device=dsnoop'''
  $ alsamixer -c 0
+
  # load-module module-udev-detect
 +
  # load-module module-detect
  
{{Note|alsamixer will not tell you which output device is set as the default. One possible cause of no sound after install is that PulseAudio detects the wrong output device as a default. Install {{Pkg|pavucontrol}} and check if there is any output on the pavucontrol panel when playing a ''.wav'' file.}}
+
* ''Optional:'' If you use {{Pkg|kmix}} you may want to control ALSA volume instead of PulseAudio volume:
 +
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
 +
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
  
==== Auto-Mute Mode ====
+
* Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
Auto-Mute Mode may be enabled. It can be disabled using {{ic|alsamixer}}.
+
:Use {{Pkg|pavucontrol}} to control PulseAudio volume if needed.
  
See http://superuser.com/questions/431079/how-to-disable-auto-mute-mode for more.
+
=== OSS ===
  
==== Bad configuration files ====
+
There are multiple ways of making OSS-only programs output to PulseAudio:
After starting PulseAudio, if the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.pulse}}. PulseAudio will automatically create new configuration files on its next start.
 
  
==== Flash content ====
+
==== ossp ====
Since Adobe Flash does not directly support PulseAudio, the recommended way is to [[PulseAudio#ALSA|configure ALSA to use the virtual PulseAudio sound card]].
 
  
Alternatively you may try out {{AUR|libflashsupport-pulse}} from the [[AUR]].
+
Install {{Pkg|ossp}} package and start {{ic|osspd.service}}.
{{Note|This may invariably crash the Flash plugin.}}
 
  
If you find audio from flash is being laggy, you might like to have flash access ALSA directly. This fixes this problem in some cases. To do this, [[#ALSA/dmix without grabbing hardware device|configure PulseAudio to use dmix]].
+
==== padsp wrapper ====
  
==== No cards ====
+
Programs using OSS can work with PulseAudio by starting it with padsp (included with PulseAudio):
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:
 
$ fuser -v /dev/snd/*
 
$ fuser -v /dev/dsp
 
  
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.
+
$ padsp OSSprogram
  
==== The only device shown is "dummy output" ====
+
A few examples:
This may be caused by different reasons, one of them being the {{ic|.asoundrc}} file in $HOME is taking precedence over the systemwide {{ic|/etc/asound.conf}}.
 
  
The user file is modified also by the tool {{ic|asoundconf}} or by its graphical variant {{ic|asoundconf-gtk}} (the latter is named "Default sound card" in the menu) as soon as it runs. Prevent the effects of {{ic|.asoundrc}} altogether by commenting the last line like this:
+
  $ padsp aumix
{{hc|.asoundrc|
+
  $ padsp sox foo.wav -t ossdsp /dev/dsp
# </home/''yourusername''/.asoundrc.asoundconf>
 
}}
 
  
Maybe some program is monopolizing the audio device:
+
You can also add a custom wrapper script like this:   
{{hc|# fuser -v /dev/snd/*|
 
                    USER      PID ACCESS COMMAND
 
/dev/snd/controlC0:  root        931 F....  timidity
 
                    bob        1195 F....  panel-6-mixer
 
/dev/snd/controlC1:  bob        1195 F....  panel-6-mixer
 
                    bob        1215 F....  pulseaudio
 
/dev/snd/pcmC0D0p:  root        931 F...m  timidity
 
/dev/snd/seq:        root        931 F....  timidity
 
/dev/snd/timer:      root        931 f....  timidity
 
}}
 
  
That means timidity blocks PulseAudio from accessing the audio devices. Just killing timidity will make the sound work again.
+
{{hc|/usr/local/bin/OSSProgram|<nowiki>
 +
#!/bin/sh
 +
exec padsp /usr/bin/OSSprogram "$@"
 +
</nowiki>}}
  
Another reason is [[FluidSynth]] conflicting with PulseAudio as discussed in [https://bbs.archlinux.org/viewtopic.php?id=154002 this thread]. The solution is to remove FluidSynth:
+
Make sure {{ic|/usr/local/bin}} comes before {{ic|/usr/bin}} in your '''PATH'''.
  
# pacman -Rnsc fluidsynth
+
=== GStreamer ===
  
==== No HDMI 5/7.1 Selection for Device  ====
+
Install {{Pkg|gst-plugins-good}}, or {{AUR|gstreamer0.10-good-plugins}} if your intended program has a legacy [[GStreamer]] implementation.
If you are unable to select 5/7.1 channel output for a working HDMI device, then turning off "stream device reading" in {{ic|/etc/pulse/default.pa}} might help.  
 
  
See [[#Fallback device is not respected]].
+
=== OpenAL ===
  
==== KDE Plasma Workspaces ====
+
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}
It may be that another output device set as preferred in phonon. Make sure that every setting reflects the preferred output device at the top, and check the playback streams tab in {{ic|kmix}} to make sure that applications are using the device for output.
 
  
To see your default audio device, you can run:
+
=== libao ===
  
pactl stat
+
Edit the libao configuration file:
 +
{{hc|/etc/libao.conf|2=default_driver=pulse}}
 +
Be sure to remove the {{ic|1=dev=default}} option of the alsa driver or adjust it to specify a specific Pulse sink name or number.
  
To see available audio devices:
+
{{Note|You could possibly also keep the libao standard of outputting to the ''alsa'' driver and its default device if you install {{pkg|pulseaudio-alsa}} since the ALSA default device then '''is''' PulseAudio.}}
  
pactl list
+
== Equalizer ==
  
To set your default audio device, use "pacmd" or add to {{ic|/etc/pulse/default.pa}}:
+
{{Warning|The equalizer module is considered unstable and might be removed from PulseAudio. For more, see the [https://lists.freedesktop.org/archives/pulseaudio-discuss/2014-March/020174.html mailing list].}}
set-default-sink alsa_output.analog-stereo
 
  
==== Failed to create sink input: sink is suspended ====
+
PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:
If you do not have any output sound and receive dozens of errors related to a suspended sink in your {{ic|journalctl -b}} log, then backup first and then delete your user-specific pulse folders:
 
  
$ rm -r ~/.pulse ~/.pulse-cookie
+
Install {{Pkg|pulseaudio-equalizer}}:
  
=== No HDMI sound output after some time with the monitor turned off ===
+
=== Load equalizer sink and dbus-protocol module ===
The monitor is connected via HDMI/DisplayPort, and the audio jack is plugged in the headphone jack of the monitor, but PulseAudio insists that it is unplugged:
 
{{hc|pactl list sinks|
 
...
 
hdmi-output-0: HDMI / DisplayPort (priority: 5900, not available)
 
...
 
}}
 
  
This leads to no sound coming from HDMI output. A workaround for this is to switch to another TTY and back again. This problem has been reported by ATI/Nvidia/Intel users.
+
$ pactl load-module module-equalizer-sink
 +
$ pactl load-module module-dbus-protocol
  
=== Can't update configuration of sound device in pavucontrol ===
+
=== GUI front-end ===
{{Pkg|pavucontrol}} is a handy GUI utility for configuring PulseAudio. Under its 'Configuration' tab, you can select different profiles for each of your sound devices e.g. analogue stereo, digital output (IEC958), HDMI 5.1 Surround etc.
 
  
However, you may run into an instance where selecting a different profile for a card results in the pulse daemon crashing and auto restarting without the new selection "sticking". If this occurs, use the other useful GUI tool, {{Pkg|paprefs}}, to check under the "Simultaneous Output" tab for a virtual simultaneous device. If this setting is active (checked), it will prevent you changing any card's profile in pavucontrol. Uncheck this setting, then adjust your profile in pavucontrol prior to re-enabling simultaneous output in paprefs.
+
run:
  
=== Simultaneous output to multiple sound cards / devices ===
+
$ qpaeq
Simultaneous output to two different devices can be very useful. For example, being able to send audio to your A/V receiver via your graphics card's HDMI output, while also sending the same audio through the analogue output of your motherboard's built-in audio. This is much less hassle than it used to be (in this example, we are using GNOME desktop).
 
  
Using {{Pkg|paprefs}}, simply select "Add virtual output device for simultaneous output on all local sound cards" from under the "Simultaneous Output" tab. Then, under GNOME's "sound settings", select the simultaneous output you have just created.
+
{{Note|If qpaeq has no effect, install {{pkg|pavucontrol}} and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}
  
If this doesn't work, try adding the following to {{ic|~/.asoundrc}}:
+
=== Load equalizer and dbus module on every boot ===
  
pcm.dsp {
+
Edit the {{ic|/etc/pulse/default.pa}} or {{ic|~/.config/pulse/default.pa}} file with your favorite editor and append the following lines:
    type plug
 
    slave.pcm "dmix"
 
}
 
  
=== Simultaneous output to multiple sinks on the same sound card not working===
+
### Load the integrated PulseAudio equalizer and D-Bus module
This can be useful for users who have multiple sound sources and want to play them on different sinks/outputs.
+
load-module module-equalizer-sink
An example use-case for this would be if you play music and also voice chat and want to output music to speakers (in this case Digital S/PDIF) and voice to headphones. (Analog)
+
load-module module-dbus-protocol
  
This is sometimes auto detected by PulseAudio but not always. If you know that your sound card can output to both Analog and S/PDIF at the same time and PulseAudio does not have this option in it's profiles in pavucontrol, or veromix then you probably need to create a configuration file for your sound card.
+
{{Note|The equalizer sink needs to be loaded after the master sink is already available.}}
  
More in detail you need to create a profile-set for your specific sound card.
+
=== Alternative equalizers ===
This is done in two steps mostly.
 
* Create udev rule to make PulseAudio choose your PulseAudio configuration file specific to the sound card.
 
* Create the actual configuration.
 
  
Create a pulseadio udev rule.
+
{{AUR|pulseaudio-equalizer-ladspa}} (based on {{Pkg|swh-plugins}}) can be used as an alternative to {{Pkg|pulseaudio-equalizer}}.
{{Note| This is only an example for Asus Xonar Essence STX.
 
Read [[udev]] to find out the correct values.}}
 
{{Note| Your configuration file should have lower number than the original PulseAudio rule to take effect.}}
 
{{hc|/usr/lib/udev/rules.d/90-pulseaudio-Xonar-STX.rules|
 
ACTION&#61;&#61;"change", SUBSYSTEM&#61;&#61;"sound", KERNEL&#61;&#61;"card*", \
 
ATTRS&#123;subsystem_vendor&#125;&#61;&#61;"0x1043", ATTRS&#123;subsystem_device&#125;&#61;&#61;"0x835c", ENV&#123;PULSE_PROFILE_SET&#125;&#61;"asus-xonar-essence-stx.conf"
 
}}
 
  
Now, create a configuration file. If you bother, you can start from scratch and make it saucy. However you can also use the default configuration file, rename it, and then add your profile there that you know works. Less pretty but also faster.
+
{{AUR|pulseeffects}} applies peak limiting, compression, reverberation, auto volume and 15 bands equalization to Pulseaudio applications output.
  
To enable multiple sinks for Asus Xonar Essence STX you need only to add this in.
+
== Applications ==
{{Note|{{ic|asus-xonar-essence-stx.conf}} also includes all code/mappings from {{ic|default.conf}}.}}
 
{{hc|/usr/share/pulseaudio/alsa-mixer/profile-sets/asus-xonar-essence-stx.conf|
 
[Profile analog-stereo+iec958-stereo]
 
description &#61; Analog Stereo Duplex + Digital Stereo Output
 
input-mappings &#61; analog-stereo
 
output-mappings &#61; analog-stereo iec958-stereo
 
skip-probe &#61; yes
 
}}
 
  
This will auto-profile your Asus Xonar Essence STX with default profiles and add your own profile so you can have multiple sinks.
+
=== QEMU ===
  
You need to create another profile in the configuration file if you want to have the same functionality with AC3 Digital 5.1 output.
+
Refer to [[QEMU#Host]] for a detailed guide on how to configure pulseaudio within [[QEMU]].
  
[https://www.freedesktop.org/wiki/Software/PulseAudio/Backends/ALSA/Profiles/ See PulseAudio article about profiles]
+
=== AlsaMixer.app ===
  
=== Disable Bluetooth support ===
+
Make {{AUR|alsamixer.app}} dockapp for the {{AUR|windowmaker}} use pulseaudio, e.g.
If you do not use Bluetooth, you may experience the following error in your journal:
+
$ AlsaMixer.app --device pulse
  
bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files
+
Here is a two examples where the first one is for ALSA and the other one is for pulseaudio. You can run multiple instances of it. Use the {{ic|-w}} option to choose which of the control buttons to bind to the mouse wheel.
 +
# AlsaMixer.app -3 Mic -1 Master -2 PCM --card 0 -w 1
 +
# AlsaMixer.app --device pulse -1 Capture -2 Master -w 2
  
To disable Bluetooth support in PulseAudio, make sure that the following lines are commented out in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):
+
{{Note|It can use only those output sinks that set as default.}}
  
{{hc|~/.config/pulse/default.pa|
+
=== XMMS2 ===
### Automatically load driver modules for Bluetooth hardware
 
#.ifexists module-bluetooth-policy.so
 
#load-module module-bluetooth-policy
 
#.endif
 
  
#.ifexists module-bluetooth-discover.so
+
Make it switch to pulseaudio output
#load-module module-bluetooth-discover
+
$ nyxmms2 server config output.plugin pulse
#.endif
+
and to alsa
}}
+
$ nyxmms2 server config output.plugin alsa
 +
To make xmms2 use a different output sink, e.g.
 +
  $ nyxmms2 server config pulse.sink alsa_output.pci-0000_04_01.0.analog-stereo.monitor
  
=== Bluetooth headset replay problems ===
+
See also the official guide [https://xmms2.org/wiki/Using_the_application].
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 reports] huge delays or even no sound when the Bluetooth connection does not send any data. This is due to the {{ic|module-suspend-on-idle}} module, which automatically suspends sinks/sources on idle. As this can cause problems with headset, the responsible module can be deactivated.
 
  
To disable loading of the {{ic|module-suspend-on-idle}} module, comment out the following line in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):
+
=== KDE Plasma Workspaces and Qt4 ===
  
{{hc|~/.config/pulse/default.pa|
+
PulseAudio will automatically be used by KDE/Qt4 applications. It is supported by default in the KDE sound mixer. For more information see the [https://www.freedesktop.org/wiki/Software/PulseAudio/Desktops/KDE/ KDE page in the PulseAudio wiki].
### Automatically suspend sinks/sources that become idle for too long
 
#load-module module-suspend-on-idle
 
}}
 
  
Finally restart PulseAudio to apply the changes.
+
One useful tidbit from that page is that {{ic|load-module module-device-manager}} should be loaded. This usually happens automatically at login through the script {{ic|/usr/bin/start-pulseaudio-x11}}; if you find that the module is not loaded automatically you can consider adding it manually to {{ic|/etc/pulse/default.pa}}. See [[#Switch on connect]] for possible conflicts with the {{ic|module-switch-on-connect}}.
  
=== Automatically switch to Bluetooth or USB headset ===
+
If the phonon-gstreamer backend is used for Phonon, GStreamer should also be configured as described in [[#GStreamer]].
Add the following:
 
{{hc|/etc/pulse/default.pa|
 
# automatically switch to newly-connected devices
 
load-module module-switch-on-connect
 
}}
 
  
=== Pulse overwrites ALSA settings ===
+
=== Audacious ===
PulseAudio usually overwrites the ALSA settings — for example set with alsamixer — at start-up, even when the ALSA daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the ALSA settings again after PulseAudio has started. Add the following command to {{ic|.xinitrc}} or {{ic|.bash_profile}} or any other [[Autostarting|autostart]] file:
 
  
restore_alsa() {
+
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.
  while [ -z "$(pidof pulseaudio)" ]; do
 
  sleep 0.5
 
  done
 
  alsactl -f /var/lib/alsa/asound.state restore
 
}
 
restore_alsa &
 
  
=== Prevent Pulse from restarting after being killed ===
+
=== Music Player Daemon (MPD) ===
Sometimes you may wish to temporarily disable Pulse. In order to do so you will have to prevent Pulse from restarting after being killed.
 
  
{{hc|~/.config/pulse/client.conf|2=
+
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio. See also [[MPD/Tips and Tricks#PulseAudio]].
# Disable autospawning the PulseAudio daemon
 
autospawn = no
 
}}
 
  
=== Daemon startup failed ===
+
=== MPlayer ===
Try resetting PulseAudio:
 
$ rm -rf /tmp/pulse* ~/.pulse*
 
$ pulseaudio -k
 
$ pulseaudio --start
 
  
If there is no server running but PulseAudio fails to start with an error message "User-configured server at ... refusing to start/autospawn", the issue may be with PulseAudio settings from a previous login. Check to see if there are any stale properties attached to the X11 root window with {{ic|pax11publish -d}}, and if there are, remove them with {{ic|pax11publish -r}} before trying to start the server. This manual cleanup is always required when using LXDM because it does not restart the X server on logout; see [[LXDM#PulseAudio]].
+
[[MPlayer]] natively supports PulseAudio output with the {{ic|-ao pulse}} option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:
 +
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}
  
==== inotify issue ====
+
=== guvcview ===
If the previous fix doesn't work, see if you get an error like this:
 
{{hc|$ pulseaudio -vvvv|
 
E: [pulseaudio] module-udev-detect.c: You apparently ran out of inotify watches, probably because Tracker/Beagle took them all away. I wished people would do their homework first and fix inotify before using it for watching whole directory trees which is something the current inotify is certainly not useful for. Please make sure to drop the Tracker/Beagle guys a line complaining about their broken use of inotify.
 
}}
 
  
In which case you have run out of inotify watches.  
+
{{Pkg|guvcview}} when using the PulseAudio input from a [[Webcam]] may have the audio input suspended resulting in no audio being recorded. You can check this by executing:
  
This can quickly be resolved by:
+
  $ pactl list sources
  # echo 100000 > /proc/sys/fs/inotify/max_user_watches
 
  
To have it permanently changed, use:
+
If the audio source is "suspended" then modifying the following line in {{ic|/etc/pulse/default.pa}} and changing:
{{hc|/etc/sysctl.d/99-sysctl.conf|2=
 
# Increase inotify max watchs per user
 
fs.inotify.max_user_watches = 100000
 
}}
 
  
=== Glitches, skips or crackling ===
+
load-module module-suspend-on-idle
The newer implementation of the PulseAudio sound server uses timer-based audio scheduling instead of the traditional, interrupt-driven approach.
+
to
 +
#load-module module-suspend-on-idle
  
Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might be glitchy without it on, so check to see what works on your system.  
+
And then either restarting PulseAudio or your computer will only idle the input source instead of suspending it. guvcview will then correctly record audio from the device.
  
To turn timer-based scheduling off add {{ic|1=tsched=0}} in {{ic|/etc/pulse/default.pa}}:
+
== Networked audio ==
{{hc|/etc/pulse/default.pa|<nowiki>
 
load-module module-udev-detect tsched=0
 
</nowiki>}}
 
  
Then restart the PulseAudio server:
+
{{Expansion|please allow for some time for me to port the most important information here -- [[User:Nodiscc|Nodiscc]]|Talk:PulseAudio#Networked_audio}}
$ pulseaudio -k
+
Play sound through the outputs of another computer on the network
$ pulseaudio --start
 
  
Do the reverse to enable timer-based scheduling, if not already enabled by default.
+
=== Basic setup with direct connection ===
  
Using Intel's IOMMU may also lead to these problems. If you are using IOMMU and experience glitches and/or skips add {{ic|<nowiki>intel_iommu=igfx_off</nowiki>}} to your kernel command line.
+
===== On the server =====
  
Please report any such cards to [http://pulseaudio.org/wiki/BrokenSoundDrivers PulseAudio Broken Sound Driver page]
+
Edit {{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}} (or {{ic|/etc/pulse/system.pa}} if PulseAudio is started in system mode) and add the following line:
  
=== Setting the default fragment number and buffer size in PulseAudio ===
+
  load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/16
  
==== Finding out your audio device parameters (1/4) ====
+
Here only client from the IPs or IPs range specified here can stream sound.
To find your sound card buffering settings:
 
$ echo autospawn = no >> ~/.config/pulse/client.conf
 
$ pulseaudio -k
 
$ LANG=C timeout --foreground -k 10 -s kill 10 pulseaudio -vvvv 2>&1 | grep device.buffering -B 10
 
$ sed -i '$d' ~/.config/pulse/client.conf
 
  
For each sound card detected by PulseAudio, you will see output similar to this:
+
To allow access from everywhere:
I: [pulseaudio] source.c:    alsa.long_card_name = "HDA Intel at 0xfa200000 irq 46"
 
I: [pulseaudio] source.c:    alsa.driver_name = "snd_hda_intel"
 
I: [pulseaudio] source.c:    device.bus_path = "pci-0000:00:1b.0"
 
I: [pulseaudio] source.c:    sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
 
I: [pulseaudio] source.c:    device.bus = "pci"
 
I: [pulseaudio] source.c:    device.vendor.id = "8086"
 
I: [pulseaudio] source.c:    device.vendor.name = "Intel Corporation"
 
I: [pulseaudio] source.c:    device.product.name = "82801I (ICH9 Family) HD Audio Controller"
 
I: [pulseaudio] source.c:    device.form_factor = "internal"
 
I: [pulseaudio] source.c:    device.string = "front:0"
 
I: [pulseaudio] source.c:    device.buffering.buffer_size = "768000"
 
I: [pulseaudio] source.c:    device.buffering.fragment_size = "384000"
 
  
Take note the buffer_size and fragment_size values for the relevant sound card.
+
  load-module module-native-protocol-tcp auth-anonymous=true
  
==== Calculate your fragment size in msecs and number of fragments (2/4) ====
+
{{Note| If {{ic|auth-ip-acl}} neither {{ic|auth-anonymous}} are specified, authentification is done via {{ic|~/.pulse-cookie}} which must be the same on clients and server.}}
PulseAudio's default sampling rate and bit depth are set to {{ic|44100Hz}} @ {{ic|16 bits}}.
 
  
With this configuration, the bit rate we need is {{ic|44100}}*{{ic|16}} = {{ic|705600}} bits per second. That's {{ic|1411200 bps}} for stereo.
+
By default PulseAudio listens on port {{ic|tcp/4713}} for incoming connections, you may need to open this port in your [[firewall]].
  
Let's take a look at the parameters we have found in the previous step:
+
===== On the client =====
  
device.buffering.buffer_size = "768000" => 768000/1411200 = 0.544217687075s = 544 msecs
+
Edit {{ic|~/.config/pulse/client.conf}} or {{ic|/etc/pulse/client.conf}}, to respectively apply this directive to one user or to all, and add :
device.buffering.fragment_size = "384000" => 384000/1411200 = 0.272108843537s = 272 msecs
 
  
==== Modify PulseAudio's configuration file (3/4) ====
+
  default-server = ''server-address''
{{hc|/etc/pulse/daemon.conf|<nowiki>
 
; default-fragments = X
 
; default-fragment-size-msec = Y
 
</nowiki>}}
 
  
In the previous step, we calculated the fragment size parameter.
+
''server-address'' can be a simple domain-name or IPv4, for more see [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/ServerStrings/ the documentation]
The number of fragments is simply buffer_size/fragment_size, which in this case ({{ic|544/272}}) is {{ic|2}}:
 
  
{{hc|/etc/pulse/daemon.conf|<nowiki>
+
It is also possible to set the server address in the environment variable {{ic|$PULSE_SERVER}}.
; default-fragments = '''2'''
 
; default-fragment-size-msec = '''272'''
 
</nowiki>}}
 
  
==== Restart the PulseAudio daemon (4/4) ====
+
== Tips and tricks ==
$ pulseaudio -k
 
$ pulseaudio --start
 
  
For more information, see: [http://forums.linuxmint.com/viewtopic.php?f=42&t=44862 Linux Mint topic]
+
{{Merge|PulseAudio/Examples|Same topic.}}
  
=== Laggy sound ===
+
=== Keyboard volume control ===
This issue is due to incorrect buffer sizes.
 
  
Either disable any modifications (if any) to these entries, or, if issue still exists, uncomment:
+
Map the following commands to your volume keys: {{ic|XF86AudioRaiseVolume}}, {{ic|XF86AudioLowerVolume}}, {{ic|XF86AudioMute}}. See [[Extra keyboard keys in Xorg]] for details.
{{hc|/etc/pulse/daemon.conf|<nowiki>
 
default-fragments = 8
 
default-fragment-size-msec = 5
 
</nowiki>}}
 
 
 
=== Choppy, overdriven sound ===
 
Choppy sound in PulseAudio can result from wrong settings for the sample rate. Try:
 
{{hc|/etc/pulse/daemon.conf|<nowiki>
 
default-sample-rate = 48000
 
</nowiki>}}
 
and restart the PulseAudio server.
 
 
 
If one experiences choppy sound in applications using openAL, change the sample rate in {{ic|/etc/openal/alsoft.conf}}:
 
frequency = 48000
 
  
Setting the PCM volume above 0 dB can cause clipping of the audio signal. Running {{ic|alsamixer -c0}} will allow you to see if this is the problem and if so fix it. Note that ALSA may not [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PulseAudioStoleMyVolumes correctly export] the dB information to PulseAudio. Try:
+
First find out which sink corresponds to the audio output you'd like to control.
{{hc|/etc/pulse/defaults.pa|<nowiki>
+
To list available sinks:
load-module module-udev-detect ignore_dB=1
+
pactl list sinks short
</nowiki>}}
 
and restart the PulseAudio server. See also [[#No sound below a volume cutoff]].
 
  
=== Volume adjustment does not work properly ===
+
Suppose sink 0 is to be used, to raise the volume:
Check:
+
sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%"
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}
 
  
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to PulseAudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).
+
To lower the volume:
 +
sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 -5%"
  
=== Per-application volumes change when the Master volume is adjusted ===
+
To mute/unmute the volume:
This is because PulseAudio uses flat volumes by default, instead of relative volumes, relative to an absolute master volume. If this is found to be inconvenient, asinine, or otherwise undesireable, relative volumes can be enabled by disabling flat volumes in the PulseAudio daemon's configuration file:
+
  pactl set-sink-mute 0 toggle
{{hc|/etc/pulse/daemon.conf|<nowiki>
 
flat-volumes = no
 
</nowiki>}}
 
and then restarting PulseAudio by executing
 
$ pulseaudio -k
 
  $ pulseaudio --start
 
  
=== Volume gets louder every time a new application is started ===
+
To mute/unmute the microphone:
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".
+
pactl set-source-mute 1 toggle
  
Fix this by disabling flat volumes, as demonstrated in the previous section. When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.
+
{{Tip|To have keyboard shortcuts operate always on the default sink, specify {{ic|@DEFAULT_SINK@}} as the sink number, for example {{ic|pactl set-sink-mute @DEFAULT_SINK@ toggle}}.}}
  
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{ic|~/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}
+
=== Play sound from a non-interactive shell (systemd service, cron) ===
  
=== No microphone on ThinkPad T400/T500/T420 ===
+
Set {{ic|XDG_RUNTIME_DIR}} before the command (replace {{ic|''user_id''}} with the ID of the user running PulseAudio):
Run:
 
alsamixer -c 0
 
Unmute and maximize the volume of the "Internal Mic".
 
  
Once you see the device with:
+
  XDG_RUNTIME_DIR=/run/user/''user_id'' paplay /usr/share/sounds/freedesktop/stereo/complete.oga
  arecord -l
 
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.
 
  
=== No microphone input on Acer Aspire One ===
+
Or use {{ic|machinectl}}:
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.
 
Reference: http://getsatisfaction.com/jolicloud/topics/deaf_internal_mic_on_acer_aspire_one#reply_2108048
 
  
=== Sound output is only mono on M-Audio Audiophile 2496 sound card ===
+
# machinectl shell .host --uid=''user_id'' /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/complete.oga
Add the following:
 
{{hc|/etc/pulseaudio/default.pa|<nowiki>
 
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7
 
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9
 
set-default-sink delta_out
 
set-default-source delta_in
 
</nowiki>}}
 
  
=== Static noise in microphone recording ===
+
=== X11 Bell Events ===
If we are getting static noise in Skype, gnome-sound-recorder, arecord, etc.'s recordings, then the sound card sample rate is incorrect. That is why there is static noise in Linux microphone recordings. To fix this, we need to set the sampling rate in {{ic|/etc/pulse/daemon.conf}} for the sound hardware.
 
  
==== Determine sound cards in the system (1/5) ====
+
To get pulseaudio to handle X11 bell events, run the following commands after the X11 session has been started:
This requires {{Pkg|alsa-utils}} and related packages to be installed:
 
{{hc|$ arecord --list-devices|
 
**** List of CAPTURE Hardware Devices ****
 
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
 
  Subdevices: 1/1
 
  Subdevice #0: subdevice #0
 
card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]
 
  Subdevices: 1/1
 
  Subdevice #0: subdevice #0
 
}}
 
  
Sound card is {{ic|hw:0,0}}.
+
pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
 +
pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY
  
==== Determine sampling rate of the sound card (2/5) ====
+
To adjust the volume of the X11 bell, run the following command:
{{hc|1=arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav|2=
 
"Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo
 
Warning: rate is not accurate (requested = 60000Hz, '''got = 96000Hz''')
 
please, try the plug plugin
 
}}
 
  
observe, the {{ic|1=got = 96000Hz}}. This is the maximum sampling rate of our card.
+
xset b 100
  
==== Setting the sound card's sampling rate into PulseAudio configuration (3/5) ====
+
100 is a percentage. This requires the {{Pkg|xorg-xset}} package. See [[Autostarting]] for a way to run these commands automatically when the X11 session is started.
The default sampling rate in PulseAudio:
 
{{hc|1=$ grep "default-sample-rate" /etc/pulse/daemon.conf|2=
 
; default-sample-rate = 44100
 
}}
 
  
{{ic|44100}} is disabled and needs to be changed to {{ic|96000}}:
+
=== Switch on connect ===
# sed 's/; default-sample-rate = 44100/default-sample-rate = 96000/g' -i /etc/pulse/daemon.conf
+
This is a module used to switch the output sound to the newly connected device. For example, if you plug in a USB headset, the output will be switched to that. If you unplug it, the output will be set back to the last device. This used to be quite buggy but got a lot of attention in PulseAudio 8.0 and should work quite well now.
  
==== Restart PulseAudio to apply the new settings (4/5) ====
+
If you just want to test the module then you can load it at runtime by calling:
  $ pulseaudio -k
+
  $ pactl load-module module-switch-on-connect
$ pulseaudio --start
 
  
==== Finally check by recording and playing it back (5/5) ====
+
If you want to make the change persistent you will have to add it to your local pulseaudio settings or to /etc/pulse/default.pa (system wide effect). In either case, add this line:
Let us record some voice using a microphone for, say, 10 seconds. Make sure the microphone is not muted and all
+
  load-module module-switch-on-connect
  $ arecord -f cd -d 10 test-mic.wav
 
  
After 10 seconds, let us play the recording...
+
{{Accuracy|Editing {{ic|/usr/bin/start-pulseaudio-x11}} will not survive package upgrade. The offending module can be unloaded in the config before loading {{ic|module-switch-on-connect}}, see [[Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset]].}}
$ aplay test-mic.wav
 
  
Now hopefully, there is no static noise in microphone recording anymore.
+
On KDE/Plasma5 you should furthermore disable module-device-manager. As soon as Plasma5 is started it loads (via start-pulseaudio-x11) the module module-device-manager for pulseaudio to manage the devices. But that module apparently conflicts with module-switch-on-connect. Therefore you should disable that module by editing /bin/start-pulseaudio-x11 and commenting the lines for KDE. Simply logout and login again and in order to renew your pulseaudio session. On connect switching should now work properly.
  
=== My Bluetooth device is paired but does not play any sound ===
+
===Script for switching analogic outputs===
[[Bluetooth#My_device_is_paired_but_no_sound_is_played_from_it|See the article in Bluetooth section]]
 
  
Starting from PulseAudio 2.99 and bluez 4.101 you should '''avoid''' using Socket interface. Do NOT use:
+
Some sound cards present the option of multiple analog outputs, being switchable through using Pulseaudio profiles. But switching manually can become a chore, so you can use the following commands to switch it:
{{hc|/etc/bluetooth/audio.conf|<nowiki>
+
$ pactl set-sink-port 'number of the card' 'port'
[General]
 
Enable=Socket
 
</nowiki>}}
 
If you face problems with A2DP and PA 2.99 make sure you have {{Pkg|sbc}} library.
 
  
=== Subwoofer stops working after end of every song  ===
+
This will set the default output to whatever port you chose.
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099
+
Example:
 +
$ pactl set-sink-port 0 "analog-output;output-speaker"
  
To fix this, must edit: {{ic|/etc/pulse/daemon.conf}} and enable {{ic|enable-lfe-remixing}} :
+
The values can be easily obtained using:
{{hc|/etc/pulse/daemon.conf|<nowiki>
+
$ pactl list
enable-lfe-remixing = yes
 
</nowiki>}}
 
  
=== PulseAudio uses wrong microphone ===
+
Current output can be obtained through:
If PulseAudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.
+
$ pactl list sinks | grep "active profile"| cut -d ' ' -f 3-
  
$ alsamixer
+
This process can be automated through a simple script. This script then can be given a shortcut by the user:
  
Press {{ic|F6}} and choose your sound card, e.g. HDA Intel. Now press {{ic|F5}} to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source.
+
{{hc|~/pa.sh (or anything the user wants)|<nowiki>
 +
#!/bin/bash
 +
# This script uses kdialog notification to warn the user of the currently swapped to profile. User could adapt it to their needs or change it.
  
Now try if the correct microphone is used for recording.
+
CURRENT_PROFILE=$(pactl list sinks | grep "active profile"| cut -d ' ' -f 3-)
  
=== Choppy sound with analog surround sound setup ===
+
if [ "$CURRENT_PROFILE" = "analog-output;output-speaker" ] ; then
The low-frequency effects (LFE) channel is not remixed per default. To enable it the following needs to be set in {{ic|/etc/pulse/daemon.conf}} :
+
        pactl set-sink-port 0 "analog-output;output-headphones-1"
{{hc|/etc/pulse/daemon.conf|<nowiki>
+
        kdialog --title "Pulseaudio" --passivepopup "Headphone" 2 &
enable-lfe-remixing = yes
+
else
 +
        pactl set-sink-port 0 "analog-output;output-speaker"     
 +
        kdialog --title "Pulseaudio" --passivepopup  "Speaker" 2 &
 +
fi
 
</nowiki>}}
 
</nowiki>}}
  
=== Unable to select surround configuration other than "Surround 4.0" ===
+
This script is intended to swap between two profiles. First checking the current profile then swapping it. Users are required to change the field 'active profile' according to the language pactl reports. Users might need to change the number of the card and the output to fit their machine.
If you're unable to set 5.1 surround output in pavucontrol because it only shows "Analog Surround 4.0 Output", open the ALSA mixer and change the output configuration there to 6 channels. Then restart pulseaudio, and pavucontrol will list many more options.
 
  
=== No sound below a volume cutoff ===
+
== Troubleshooting ==
Known issue (won't fix): https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/223133
 
  
If sound does not play when PulseAudio's volume is set below a certain level, try setting {{ic|1=ignore_dB=1}} in {{ic|/etc/pulse/default.pa}}:
+
See [[PulseAudio/Troubleshooting]].
{{hc|/etc/pulse/default.pa|<nowiki>
 
load-module module-udev-detect ignore_dB=1
 
</nowiki>}}
 
  
However, be aware that it may cause another bug preventing PulseAudio to unmute speakers when headphones or other audio devices are unplugged.
+
== See also ==
 
 
=== Low volume for internal microphone ===
 
If you experience low volume on internal notebook microphone, try setting:
 
{{hc|/etc/pulse/default.pa|<nowiki>
 
set-source-volume 1 300000
 
</nowiki>}}
 
 
 
=== Clients alter master output volume (a.k.a. volume jumps to 100% after running application) ===
 
If changing the volume in specific applications or simply running an application changes the master output volume this is likely due to flat volumes mode of pulseaudio. Before disabling it, KDE users should try lowering their system notifications volume in ''System Settings -> Application and System Notifications -> Manage Notifications'' under the ''Player Settings'' tab to something reasonable. Changing the ''Event Sounds'' volume in KMix or another volume mixer application will not help here. This should make the flat-volumes mode work out as intended, if it does not work, some other application is likely requesting 100% volume when its playing something. If all else fails, you can try to disable flat-volumes:
 
{{hc|/etc/pulse/daemon.conf|<nowiki>
 
flat-volumes = no
 
</nowiki>}}
 
Then restart PulseAudio daemon:
 
# pulseaudio -k
 
# pulseaudio --start
 
 
 
===Realtime scheduling===
 
If rtkit does not work, you can manually set up your system to run PulseAudio with real-time scheduling, which can help performance. To do this, add the following lines to {{ic|/etc/security/limits.conf}}:
 
@pulse-rt - rtprio 9
 
@pulse-rt - nice -11
 
 
 
Afterwards, you need to add your user to the {{ic|pulse-rt}} group:
 
# gpasswd -a <user> pulse-rt
 
 
 
=== No sound after resume from suspend ===
 
If audio generally works, but stops after resume from suspend, try "reloading" PulseAudio by executing:
 
$ /usr/bin/pasuspender /bin/true
 
 
 
This is better than completely killing and restarting it ({{ic|pulseaudio -k}} followed by {{ic|pulseaudio --start}}), because it doesn't break already running applications.
 
 
 
If the above fixes your problem, you may wish to automate it, by creating a systemd service file.
 
 
 
1. Create the template service file in {{ic|/etc/systemd/system/resume-fix-pulseaudio@.service}}:
 
 
 
[Unit]
 
Description=Fix PulseAudio after resume from suspend
 
After=suspend.target
 
 
[Service]
 
User=%I
 
Type=oneshot
 
Environment="XDG_RUNTIME_DIR=/run/user/%U"
 
ExecStart=/usr/bin/pasuspender /bin/true
 
 
[Install]
 
WantedBy=suspend.target
 
 
 
2. Enable it for your user account
 
 
 
# systemctl enable resume-fix-pulseaudio@YOUR_USERNAME_HERE.service
 
 
 
3. Reload systemd
 
 
 
# systemctl --system daemon-reload
 
 
 
=== ALSA channels mute when headphones are plugged/unplugged improperly ===
 
If when you unplug your headphones or plug them in the audio remains muted in alsamixer on the wrong channel due to it being set to 0%, you may be able to fix it by opening {{ic|/etc/pulse/default.pa}} and commenting out the line:
 
load-module module-switch-on-port-available
 
  
=== pactl "invalid option" error with negative percentage arguments ===
+
* [https://www.freedesktop.org/wiki/Software/PulseAudio/ PulseAudio official website], including documentation
{{ic|pactl}} commands that take negative percentage arguments will fail with an 'invalid option' error. Use the standard shell '--' pseudo argument
+
* [https://gavv.github.io/blog/pulseaudio-under-the-hood/ Pulseaudio under the hood]
to disable argument parsing before the negative argument. ''e.g.'' {{ic|pactl set-sink-volume 1 -- -5%}}.
 
 
 
===Daemon already running===
 
On some systems, PulseAudio may be started multiple times. journalctl will report:
 
 
 
[pulseaudio] pid.c: Daemon already running.
 
 
 
Make sure to use only one method of autostarting applications. {{Pkg|pulseaudio}} includes these files:
 
 
 
* {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}}
 
* {{ic|/etc/xdg/autostart/pulseaudio.desktop}}
 
* {{ic|/etc/xdg/autostart/pulseaudio-kde.desktop}}
 
 
 
Also check user autostart files and directories, such as [[xinitrc]], {{ic|~/.config/autostart/}} etc.
 
 
 
=== Fallback device is not respected ===
 
PulseAudio does not have a true default device. Instead it uses a [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/DefaultDevice/ "fallback"], which only applies to new sound streams. This means previously run applications are not affected by the newly set fallback device.
 
 
 
Only {{Pkg|gnome-control-center}} and {{Pkg|mate-media-pulseaudio}} handle this gracefully. Alternatively:
 
 
 
1. Move the old streams in {{Pkg|pavucontrol}} manually to the new sound card.
 
 
 
2. Stop Pulse, erase the "stream-volumes" in {{ic|~/.pulse}} and restart Pulse. This also resets application volumes.
 
 
 
3. Disable stream device reading. This may be not wanted when using different soundcards with different applications.
 
{{hc|/etc/pulse/defaults.pa|<nowiki>
 
load-module module-stream-restore restore_device=false
 
</nowiki>}}
 
 
 
== See also ==
 
* [http://www.alsa-project.org/main/index.php/Asoundrc http://www.alsa-project.org/main/index.php/Asoundrc] - ALSA wiki on .asoundrc
 
* [http://www.pulseaudio.org/ http://www.pulseaudio.org/] - PulseAudio official site
 
* [http://www.pulseaudio.org/wiki/FAQ http://www.pulseaudio.org/wiki/FAQ] - PulseAudio FAQ
 

Latest revision as of 19:22, 14 February 2018

PulseAudio PulseAudio is a general purpose sound server intended to run as a middleware between your applications and your hardware devices, either using ALSA or OSS. It also offers easy network streaming accross local devices using Avahi if enabled. While its main purpose is to ease audio configuration, its modular design allows more advanced users to configure the daemon precisely to best suit their needs.

Note: Some confusion may occur between ALSA and PulseAudio. ALSA includes a Linux kernel component with sound card drivers, as well as a userspace component, libalsa.[1] PulseAudio builds only on the kernel component, but offers compatibility with libalsa through pulseaudio-alsa.[2]

Installation

Install the pulseaudio package.

Note: Some PulseAudio modules have been split from the main package and must be installed separately if needed.

Front-ends

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Application lists should use Template:App. (Discuss in Talk:PulseAudio#)

There are a number of front-ends available for controlling the PulseAudio daemon:

Tip: The non-standalone versions of pasystray can install both GTK2 and GTK3 versions and requires choosing which during build. The standalone versions install a single version.

Configuration

Merge-arrows-2.pngThis article or section is a candidate for merging with PulseAudio/Configuration.Merge-arrows-2.png

Notes: Configuration should stay in the main article, so the linked page should be merged here. (Discuss in Talk:PulseAudio#Abandoned draft)

By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirects all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks.

While PulseAudio usually runs fine out of the box and requires only minimal configuration, advanced users can change almost every aspect of the daemon by either altering the default configuration file to disable modules or writing your own from scratch.

PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its modules except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules, including PulseAudio's native protocol itself (provided by module-native-protocol-unix). Clients reach the server through one of many protocol modules that will accept audio from external sources, route it through PulseAudio and eventually have it go out through a final other module. The output module does not have to be an actual sound output: it can dump the stream into a file, stream it to a broadcasting server such as Icecast, or even just discard it.

You can find a detailed list of all available modules at Pulseaudio Loadable Modules. To enable them you can just add a line load-module <module-name-from-list> to ~/.config/pulse/default.pa.

Configuration files

PulseAudio will first look for configuration files in the home directory ~/.config/pulse, then system-wide /etc/pulse.

Tip:
  • It is strongly suggested not to edit system-wide configuration files, but rather edit user ones. Create the ~/.config/pulse directory, then copy the system configuration files into it and edit according to your need.
  • Make sure you keep user configuration in sync with changes to the packaged files in /etc/pulse/. Otherwise, PulseAudio may refuse to start due to configuration errors.
  • There is usually no need to add your user to the audio group, as PulseAudio uses udev and logind to give access dynamically to the currently "active" user. Exceptions would include running the machine headless so that there is no currently "active" user.

daemon.conf

This is the main configuration file to configure the daemon itself. It defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. The defaults are sensible for most users, see the pulse-daemon.conf(5) manpage for additional information. Boolean options accepts any of these: true, yes, on and 1 as well as false, no, off and 0.

Note: PulseAudio does not perform tilde expansion on paths in this file. Use absolute paths for any files.
Notable configuration options
Option Description
daemonize Controls whether the server will daemonize itself and return. Set to no when debugging so you can see the debugging information on the terminal.
resample-method Which resampler to use when audio with incompatible sample rates needs to be passed between modules (e.g. playback of 96kHz audio on hardware which only supports 48kHz). The available resamplers can be listed with $ pulseaudio --dump-resample-methods. Choose the best tradeoff between CPU usage and audio quality for the present use-case.
Tip: In some cases PulseAudio will generate a high CPU load. This can happen when multiple streams are resampled (individually). If this is a common use-case in a workflow, it should be considered to create an additional sink at a matching sample rate which can then be fed into the main sink, resampling only once.
avoid-resampling With avoid-resampling = yes, PulseAudio automatically configures the hardware to the sample rate which the application uses, if the hardware supports this sample rate (needs PA 11 or higher)
Warning: Enabling this feature might cause audio distortion, therefore it is disabled by default, see the release notes for more information.
enable-remixing When the input and output have a different channel count (for example, outputting a 6 channel movie into a stereo sink), pulse can either remix all the channels (default, yes) or just trivially map the channels by their name (left goes to left, right to right, all others ignored) when no
system-instance If set to yes, run the daemon as a system-wide instance. Highly discouraged as it can introduce security issues. Useful on Multiseat systems, or headless systems that have no real local users. Defaults to no.
flat-volumes flat-volumes scales the device-volume with the volume of the "loudest" application. For example, raising the VoIP call volume will raise the hardware volume and adjust the music-player volume so it stays where it was, without having to lower the volume of the music-player manually. Defaults to yes upstream, but to no within Arch.
Note: The default behavior upstream can sometimes be confusing and some applications, unaware of this feature, can set their volume to 100% at startup, potentially blowing your speakers or your ears. This is why Arch defaults to the classic (ALSA) behavior by setting this to no.
realtime-scheduling If your kernel supports realtime scheduling (for instance, Kernels#-rt[broken link: invalid section] or Kernels#-ck[broken link: invalid section]), set this to yes to ensure PulseAudio can deliver low-latency glitch-free playback. You can adjust realtime-priority as well to have it use the correct priority, especially when JACK is also running on the system.
nice-level Since PulseAudio runs in userspace and involves inter-process communication, audio can be subject to dropouts if the daemon doesn't have enough CPU time to process the audio. The default usually is enough, but can be tweaked to give pulse the wanted priority over (or below) other applications.
exit-idle-time If you want to run PulseAudio only when needed and use ALSA otherwise, you can set a delay in seconds after which the daemon will automatically shutdown after all clients are disconnected. Set it to -1 to disable this feature.
log-level When debugging, you may want to increase the logging level of the daemon to see exactly why a specific module fails to load. High logging levels will sometimes print useful information such as detected minimum latency for the system, which can then be used to tweak default-fragments and default-fragment-size-msec.
default-sample-format Usually doesn't need change, but if your sound card's native format is diffent performance and quality can be improved by setting the right format here.
default-sample-rate The default sample rate user by pulse unless overriden at module level. Change this if your sound card doesn't support 44100Hz or if you wish to upsample all audio. See previous note about CPU usage.
alternate-sample-rate To fix a common limitation where movies at 48000Hz were needlessly downsampled to 44100Hz, some modules support changing their sample rate dynamically to avoid resampling when possible. See manual for more in-depth information. Usually don't need any change.
default-channels The default number of channels when not specified. Usually don't need any change as you can configure more channels on per-module basis.
default-fragments Audio samples are split into multiple fragments of default-fragment-size-msec each. The larger the buffer is, the less likely audio will skip when the system is overloaded. On the downside this will increase the overall latency. Increase this value if you have issues.
default-fragment-size-msec The size in milliseconds of each fragment. This is the amount of data that will be processed at once by the daemon. TODO: Verify

default.pa

This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additional commands can be sent at runtime using $ pactl or $ pacmd. The startup script can also be provided on the command line by starting PulseAudio in a terminal using $ pulseaudio -nC. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self-explanatory, consult pulse-cli-syntax(5) for the details of the syntax.

Tip:
  • Rather than being a complete copy, ~/.config/pulse/default.pa can start with the line .include /etc/pulse/default.pa and then just override the defaults.
  • Run $ pacmd list-sinks|egrep -i 'index:|name:' to list available sinks. The present default sink is marked with an asterisk.
  • Edit ~/.config/pulse/default.pa to insert/alter the set-default-sink command using the sink's name as the numbering cannot be guaranteed repeatable.

client.conf

This is the configuration file read by every PulseAudio client application. It is used to configure runtime options for individual clients. It can be used to set and configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.

Configuration command

The main command to configure a server during runtime is $ pacmd. Run $ pacmd --help for a list options, or just run $ pacmd to enter the shell interactive mode and Ctrl+d to exit. All modifications will immediately be applied.

Once your new settings have been tested and meet your needs, edit the default.pa accordingly to make the change persistent. See PulseAudio/Examples for some basic settings.

Tip: leave the load-module module-default-device-restore line in the default.pa file untouched. It will allow you to restart the server in its default state, thus dismissing any wrong setting.

It is important to understand that the "sources" (processes, capture devices) and "sinks" (sound cards, servers, other processes) accessible and selectable through PulseAudio depend upon the current hardware "Profile" selected. These "Profiles" are those ALSA "pcms" listed by the command aplay -L, and more specifically by the command pacmd list-cards, which will include a line "index:", a list beginning "profiles:", and a line "active profile: <...>" in the output, among other things. "Profiles" correspond to different card input/output configurations, notably the number of available input/output channels.

The "active profile" can be set with the command pacmd set-card-profile INDEX PROFILE, with no comma separating INDEX and PROFILE, where INDEX is just the number on the line "index:" and a PROFILE name is everything shown from the beginning of any line under "profile:" to just before the colon and first space, as shown by the command pacmd list-cards. For instance, pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo.

It may be easier to select a "Profile" with a graphical tool like pavucontrol, under the "Configuration" tab, or KDE System Settings, "Multimedia/Audio and Video Settings", under the "Audio Hardware Setup" tab. Each audio "Card", which are those devices listed by the command aplay -l, or again by the command pacmd list-cards, will have its own selectable "Profile". When a "Profile" has been selected, the then available "sources" and "sinks" can be seen by using the commands pacmd list-sources and pacmd list-sinks. Note that the "index" of the available sources and sinks will change each time a card profile is changed.

The selected "Profile" can be an issue for some applications, especially the Adobe Flash players, typically /usr/lib/mozilla/plugins/libflashplayer.so and /usr/lib/PepperFlash/libpepflashplayer.so. Often, these Flash players will only work when one of the Stereo profiles is selected, and otherwise, will play video with no sound, or will simply "crash". When all else fails, you might try selecting a different profile.

Of course, when configuring some variation of Surround Sound in PulseAudio, the appropriate Surround profile will have to be selected, before Surround Sound will work, or in order to do things like remap the speaker channels.

Running

PulseAudio on Arch has pulseaudio.socket enabled by default for the systemd/User instance. This means that PulseAudio will automatically start when needed.

Note:
  • To disable pulseaudio.socket, make sure that $XDG_CONFIG_HOME/systemd/user/ exists and run systemctl --user mask pulseaudio.socket.
  • Many desktop environments autostart programs based on desktop files in the /etc/xdg/autostart/ directory. In this case, PulseAudio will be launched automatically regardless of the socket activation status.

For more information, see PulseAudio: Running.

Back-end configuration

ALSA

If you have applications that do not support PulseAudio explicitly but rely on ALSA, these applications will try to access the sound card directly via ALSA and will therefore bypass PulseAudio. PulseAudio will thus not have access to the sound card any more. As a result, all applications relying on PulseAudio will not be working any more, leading to this issue. To prevent this, you will need to install the pulseaudio-alsa package. It contains the necessary /etc/asound.conf for configuring ALSA to use PulseAudio. Also make sure that ~/.asoundrc does not exist, as it would override the /etc/asound.conf file.

Please also install lib32-libpulse and lib32-alsa-plugins if you run a x86_64 system and want to have sound for 32-bit multilib programs like Wine and Steam.

To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module snd_pcm_oss is not being loaded at boot. If it is currently loaded (lsmod | grep oss), disable it by executing:

# rmmod snd_pcm_oss

Expose PulseAudio sources, sinks and mixers to ALSA

Although pulseaudio-alsa contains the necessary configuration file to allow ALSA applications to use PulseAudio's default device, ALSA's pulse plugin is more versatile than that:

~/.asoundrc (or /etc/asound.conf)
# Create an alsa input/output using specific PulseAudio sources/sinks
 pcm.pulse-example1 {
     type pulse
     device "my-combined-sink" # name of a source or sink
     fallback "pulse-example2" # if combined not available
 }
 
 pcm.pulse-example2 {
     type pulse
     device "other-sound-card" # name of a source or sink
     # example: device "alsa_output.pci-0000_00_1b.0.analog-stereo"
 }
 
 # Create an alsa mixer using specific PulseAudio sources/sinks
 # these can be tested with "alsamixer -D pulse-example3"
 ctl.pulse-example3 {
     type pulse
     device "my-output" # name of source or sink to control
 
     # example: always control the laptop speakers:
     # device "alsa_output.pci-0000_00_1b.0.analog-stereo"
     fallback "pulse-example4" # supports fallback too
 }
 
 # Mixers also can control a specific source and sink, separately:
 ctl.pulse-example4 {
     type pulse
     sink "my-usb-headphones"
     source "my-internal-mic"
     
     # example: output to HDMI, record using internal
     sink "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
     source "alsa_input.pci-0000_00_1b.0.analog-stereo"
 }
 
 # These can override the default mixer (example: for pnmixer integration)
 ctl.!default {
     type pulse
     sink "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
     source "alsa_input.pci-0000_00_1b.0.analog-stereo"
 }

The source code can be read to know all available options.

ALSA/dmix without grabbing hardware device

Note: This section describes alternative configuration, which is generally not recommended.

You may want to use ALSA directly in most of your applications while still being able to use applications which require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.

  • Remove package pulseaudio-alsa, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
  • Edit /etc/pulse/default.pa.
Find and uncomment lines which load back-end drivers. Add device parameters as follows. Then find and comment lines which load autodetect modules.
load-module module-alsa-sink device=dmix
load-module module-alsa-source device=dsnoop
# load-module module-udev-detect
# load-module module-detect
  • Optional: If you use kmix you may want to control ALSA volume instead of PulseAudio volume:
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
  • Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
Use pavucontrol to control PulseAudio volume if needed.

OSS

There are multiple ways of making OSS-only programs output to PulseAudio:

ossp

Install ossp package and start osspd.service.

padsp wrapper

Programs using OSS can work with PulseAudio by starting it with padsp (included with PulseAudio):

$ padsp OSSprogram

A few examples:

$ padsp aumix
$ padsp sox foo.wav -t ossdsp /dev/dsp

You can also add a custom wrapper script like this:

/usr/local/bin/OSSProgram
#!/bin/sh
exec padsp /usr/bin/OSSprogram "$@"

Make sure /usr/local/bin comes before /usr/bin in your PATH.

GStreamer

Install gst-plugins-good, or gstreamer0.10-good-pluginsAUR if your intended program has a legacy GStreamer implementation.

OpenAL

OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so:
/etc/openal/alsoft.conf
drivers=pulse,alsa

libao

Edit the libao configuration file:

/etc/libao.conf
default_driver=pulse

Be sure to remove the dev=default option of the alsa driver or adjust it to specify a specific Pulse sink name or number.

Note: You could possibly also keep the libao standard of outputting to the alsa driver and its default device if you install pulseaudio-alsa since the ALSA default device then is PulseAudio.

Equalizer

Warning: The equalizer module is considered unstable and might be removed from PulseAudio. For more, see the mailing list.

PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:

Install pulseaudio-equalizer:

Load equalizer sink and dbus-protocol module

$ pactl load-module module-equalizer-sink
$ pactl load-module module-dbus-protocol

GUI front-end

run:

$ qpaeq
Note: If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.

Load equalizer and dbus module on every boot

Edit the /etc/pulse/default.pa or ~/.config/pulse/default.pa file with your favorite editor and append the following lines:

### Load the integrated PulseAudio equalizer and D-Bus module
load-module module-equalizer-sink
load-module module-dbus-protocol
Note: The equalizer sink needs to be loaded after the master sink is already available.

Alternative equalizers

pulseaudio-equalizer-ladspaAUR (based on swh-plugins) can be used as an alternative to pulseaudio-equalizer.

pulseeffectsAUR applies peak limiting, compression, reverberation, auto volume and 15 bands equalization to Pulseaudio applications output.

Applications

QEMU

Refer to QEMU#Host for a detailed guide on how to configure pulseaudio within QEMU.

AlsaMixer.app

Make alsamixer.appAUR dockapp for the windowmakerAUR use pulseaudio, e.g.

$ AlsaMixer.app --device pulse

Here is a two examples where the first one is for ALSA and the other one is for pulseaudio. You can run multiple instances of it. Use the -w option to choose which of the control buttons to bind to the mouse wheel.

# AlsaMixer.app -3 Mic -1 Master -2 PCM --card 0 -w 1
# AlsaMixer.app --device pulse -1 Capture -2 Master -w 2
Note: It can use only those output sinks that set as default.

XMMS2

Make it switch to pulseaudio output

$ nyxmms2 server config output.plugin pulse

and to alsa

$ nyxmms2 server config output.plugin alsa

To make xmms2 use a different output sink, e.g.

 $ nyxmms2 server config pulse.sink alsa_output.pci-0000_04_01.0.analog-stereo.monitor

See also the official guide [3].

KDE Plasma Workspaces and Qt4

PulseAudio will automatically be used by KDE/Qt4 applications. It is supported by default in the KDE sound mixer. For more information see the KDE page in the PulseAudio wiki.

One useful tidbit from that page is that load-module module-device-manager should be loaded. This usually happens automatically at login through the script /usr/bin/start-pulseaudio-x11; if you find that the module is not loaded automatically you can consider adding it manually to /etc/pulse/default.pa. See #Switch on connect for possible conflicts with the module-switch-on-connect.

If the phonon-gstreamer backend is used for Phonon, GStreamer should also be configured as described in #GStreamer.

Audacious

Audacious natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.

Music Player Daemon (MPD)

configure MPD to use PulseAudio. See also MPD/Tips and Tricks#PulseAudio.

MPlayer

MPlayer natively supports PulseAudio output with the -ao pulse option. It can also be configured to default to PulseAudio output, in ~/.mplayer/config for per-user, or /etc/mplayer/mplayer.conf for system-wide:

/etc/mplayer/mplayer.conf
ao=pulse

guvcview

guvcview when using the PulseAudio input from a Webcam may have the audio input suspended resulting in no audio being recorded. You can check this by executing:

$ pactl list sources

If the audio source is "suspended" then modifying the following line in /etc/pulse/default.pa and changing:

load-module module-suspend-on-idle

to

#load-module module-suspend-on-idle

And then either restarting PulseAudio or your computer will only idle the input source instead of suspending it. guvcview will then correctly record audio from the device.

Networked audio

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please allow for some time for me to port the most important information here -- Nodiscc (Discuss in Talk:PulseAudio#Networked_audio)

Play sound through the outputs of another computer on the network

Basic setup with direct connection

On the server

Edit ~/.config/pulse/default.pa or /etc/pulse/default.pa (or /etc/pulse/system.pa if PulseAudio is started in system mode) and add the following line:

 load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/16

Here only client from the IPs or IPs range specified here can stream sound.

To allow access from everywhere:

 load-module module-native-protocol-tcp auth-anonymous=true
Note: If auth-ip-acl neither auth-anonymous are specified, authentification is done via ~/.pulse-cookie which must be the same on clients and server.

By default PulseAudio listens on port tcp/4713 for incoming connections, you may need to open this port in your firewall.

On the client

Edit ~/.config/pulse/client.conf or /etc/pulse/client.conf, to respectively apply this directive to one user or to all, and add :

 default-server = server-address

server-address can be a simple domain-name or IPv4, for more see the documentation

It is also possible to set the server address in the environment variable $PULSE_SERVER.

Tips and tricks

Merge-arrows-2.pngThis article or section is a candidate for merging with PulseAudio/Examples.Merge-arrows-2.png

Notes: Same topic. (Discuss in Talk:PulseAudio#)

Keyboard volume control

Map the following commands to your volume keys: XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioMute. See Extra keyboard keys in Xorg for details.

First find out which sink corresponds to the audio output you'd like to control. To list available sinks:

pactl list sinks short

Suppose sink 0 is to be used, to raise the volume:

sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%"

To lower the volume:

sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 -5%"

To mute/unmute the volume:

pactl set-sink-mute 0 toggle

To mute/unmute the microphone:

pactl set-source-mute 1 toggle
Tip: To have keyboard shortcuts operate always on the default sink, specify @DEFAULT_SINK@ as the sink number, for example pactl set-sink-mute @DEFAULT_SINK@ toggle.

Play sound from a non-interactive shell (systemd service, cron)

Set XDG_RUNTIME_DIR before the command (replace user_id with the ID of the user running PulseAudio):

XDG_RUNTIME_DIR=/run/user/user_id paplay /usr/share/sounds/freedesktop/stereo/complete.oga

Or use machinectl:

# machinectl shell .host --uid=user_id /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/complete.oga

X11 Bell Events

To get pulseaudio to handle X11 bell events, run the following commands after the X11 session has been started:

pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY

To adjust the volume of the X11 bell, run the following command:

xset b 100

100 is a percentage. This requires the xorg-xset package. See Autostarting for a way to run these commands automatically when the X11 session is started.

Switch on connect

This is a module used to switch the output sound to the newly connected device. For example, if you plug in a USB headset, the output will be switched to that. If you unplug it, the output will be set back to the last device. This used to be quite buggy but got a lot of attention in PulseAudio 8.0 and should work quite well now.

If you just want to test the module then you can load it at runtime by calling:

$ pactl load-module module-switch-on-connect

If you want to make the change persistent you will have to add it to your local pulseaudio settings or to /etc/pulse/default.pa (system wide effect). In either case, add this line:

load-module module-switch-on-connect

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Editing /usr/bin/start-pulseaudio-x11 will not survive package upgrade. The offending module can be unloaded in the config before loading module-switch-on-connect, see Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset. (Discuss in Talk:PulseAudio#)

On KDE/Plasma5 you should furthermore disable module-device-manager. As soon as Plasma5 is started it loads (via start-pulseaudio-x11) the module module-device-manager for pulseaudio to manage the devices. But that module apparently conflicts with module-switch-on-connect. Therefore you should disable that module by editing /bin/start-pulseaudio-x11 and commenting the lines for KDE. Simply logout and login again and in order to renew your pulseaudio session. On connect switching should now work properly.

Script for switching analogic outputs

Some sound cards present the option of multiple analog outputs, being switchable through using Pulseaudio profiles. But switching manually can become a chore, so you can use the following commands to switch it:

$ pactl set-sink-port 'number of the card' 'port'

This will set the default output to whatever port you chose. Example:

$ pactl set-sink-port 0 "analog-output;output-speaker" 

The values can be easily obtained using:

$ pactl list

Current output can be obtained through:

$ pactl list sinks | grep "active profile"| cut -d ' ' -f 3-

This process can be automated through a simple script. This script then can be given a shortcut by the user:

~/pa.sh (or anything the user wants)
#!/bin/bash
# This script uses kdialog notification to warn the user of the currently swapped to profile. User could adapt it to their needs or change it.

CURRENT_PROFILE=$(pactl list sinks | grep "active profile"| cut -d ' ' -f 3-)

if [ "$CURRENT_PROFILE" = "analog-output;output-speaker" ] ; then
        pactl set-sink-port 0 "analog-output;output-headphones-1"
        kdialog --title "Pulseaudio" --passivepopup "Headphone" 2 & 
else 
        pactl set-sink-port 0 "analog-output;output-speaker"      
        kdialog --title "Pulseaudio" --passivepopup  "Speaker" 2 &
fi

This script is intended to swap between two profiles. First checking the current profile then swapping it. Users are required to change the field 'active profile' according to the language pactl reports. Users might need to change the number of the card and the output to fit their machine.

Troubleshooting

See PulseAudio/Troubleshooting.

See also