This is an old revision of the document!
Table of Contents
Using Pulseaudio as non-default audio manager
With the release of the first beta of what will be version 14.2, PulseAudio has been introduced as default audio server in Slackware Linux.
This historical change comes out mostly from necessity, as the bluetooth stack BlueZ has dropped the ALSA plugin for audio output, making the presence of PulseAudio mandatory for playing any audio coming from Bluetooth devices.
From Slackware's Changelog:
After upgrading to BlueZ 5 recently, everything seemed to be working great, but then it was pointed out that Bluetooth audio was no longer working. The reason was that the newer BlueZ branch had dropped ALSA support and now required PulseAudio. So with some trepidation, we began investigating adding PulseAudio to Slackware. Going back to BlueZ 4 wasn't an option with various dependent projects either having dropped support for it, or considering doing so. After several iterations here refining the foundation packages and recompiling and tweaking other packages to use PulseAudio, it's working well and you'll likely not notice much of a change. But if you're using Bluetooth audio, or needing to direct audio through HDMI, you'll probably find it a lot easier to accomplish that. Best of all, we're finally a modern, relevant Linux distro! ;-)
Before this moment, there was no technical need for introducing PulseAudio as a basic component of the distribution, and linking the audio components directly to ALSA devices gave all the features needed by users without PA's known backsides.
Goal of this guide
PulseAudio has become the default audio manager in the distribution, and it is configured for taking ownership of the audio card in the system so that all the components needing access to audio must refer to it.
For this reason, multiple software packages have already been recompiled to enable dependency on PulseAudio, and others will probably follow before the release cycle of 14.2 is complete. This equates Slackware to all other Linux distributions that had previously adopted PulseAudio.
The goal of this guide is giving instructions on how to configure PulseAudio in Slackware-current and upcoming 14.2 as an additional audio system while keeping direct access to ALSA devices as the default.
It is possible to configure PulseAudio as a "dumb pipe" that streams audio to ALSA's dmix device, without directly grabbing the audio card and allowing other software to stream into dmix device as well, so that all audio sources are mixed together.
I will also try to keep track of the changes in compilation parameters of various packages that must be reverted in order to have them use ALSA as their default output.
The final result should be having /usr/bin/pulseaudio
process started as less as possible, ideally only when the components that cannot work without it are in use, while the rest of the system will use ALSA.
Basic Pulseaudio configuration
Steps to revert ALSA configuration to playing directly to audio hardware instead of using Pulseaudio are:
- Remove
/etc/asound.conf
file that has been installed by thealsa-lib
package
- Remove
alsa-plugins
package
# removepkg alsa-plugins
The rationale for this is:
l/alsa-plugins-1.1.0-x86_64-1.txz: Added. This provides a plugin to redirect ALSA output to PulseAudio.
- 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
- Edit
/etc/pulse/daemon.conf
- Add configuration for having Pulseaudio daemon immediately exit as soon as the audio source triggering it has ended:
exit-idle-time = 0
- Optional: add configuration for keeping Pulseaudio from altering volume levels that ALSA is handling
flat-volumes = yes
Changes related to X11
The pulseaudio
package will install /etc/xdg/autostart/pulseaudio.desktop
.
This file contains configuration responsible for registering Pulseaudio with the current X11 session and making it available to all programs running in X11 environment.
An XSMP connection between Pulseaudio daemon and the X11 session will be created, and this will make the daemon stay started during all the session, even if no Pulseaudio clients are actually in use.
$ pactl list clients Client #0 Driver: module-x11-xsmp.c Owner Module: 4 Properties: application.name = "XSMP Session on KDE as 10d7cad6d0000145322327400000022300109" xsmp.vendor = "KDE" xsmp.client.id = "10d7cad6d0000145322327400000022300109"
But without this connection no audio software running in the graphical session will be able to connect to Pulseaudio daemon even if it correctly starts on demand.
If you are fine with having /usr/bin/pulseaudio
running idle in the system and being occasionally used by the clients depending on it, you can leave things untouched.
If you want it to start and stay running only for the time it's actually needed and exit right after closing any related client then you can take this solution into consideration:
remove or rename the file /etc/xdg/autostart/pulseaudio.desktop
. This will avoid PA being pre-started at each user login to an X11 session.
Create a script /usr/local/bin/pa-unreg/
with the following:
#!/bin/bash if [ "$(pidof pulseaudio)" ] then /usr/bin/pactl unload-module module-x11-xsmp 1>/dev/null 2>/dev/null fi
Install the following line in user's personal crontab:
$ crontab -l # Unregister Pulseaudio XSMP module */10 * * * * /usr/local/bin/pa-unreg
This command running every 10 minutes will unregister any Pulseaudio daemon currently running from the XSMP session. When Pulseaudio daemon starts it will initially register itself and the client triggering it will be able to connect. Then within the following 10 minutes the registration will be removed, but currently established client connections will stay active until when necessary. When clients will exit, the daemon will exit as well because no kind of session is still alive.
Changes related to Desktop Environments
KDE 4
As of the current date (January 2016), Slackware-current and upcoming release 14.2 include KDE 4.14.3. This version is known as being the last official release of KDE 4. No further releases are planned, and no further packages should arrive in the distribution, unless any recompilation should be required because of dependency changes.
With the arrival of Pulseaudio, some packages related to KDE have been recompiled to enable PA support by linking them to its libraries.
Notably these packages are:
phonon-4.8.3
(the abstraction layer for multimedia streams)kmix-4.14.3
(the mixer for handling volume levels)kde-runtime-4.14.3
(probably for the Control Panel tabs related to audio configuration)
This means that as soon as the user logs into a KDE session the /usr/bin/pulseaudio
will be started and will stay running even after we have applied the previously listed changes.
Phonon
It handles all audio streams coming from KDE programs (including Amarok, for example). Now it is linked to Pulseaudio libraries and sends all them through it. Reverting it to the previous condition will make all KDE multimedia applications go through ALSA again, without any individual change.
There is no runtime option for making it use ALSA output when it's compiled for Pulseaudio, so you will need to recompile it with explicit exclusion of Pulseaudio support, and then replace the official Slackware package with your own.
You will need this addition to CMake configuration parameters:
cmake \ [...] -DWITH_PulseAudio=BOOL:OFF \ -DPHONON_PULSESUPPORT=FALSE \ [...]
You can replace the PA-dependant package with this other one with the command:
# upgradepkg --reinstall phonon-4.8.3-x86_64-1.txz
KMix
The audio mixer has been recompiled for controlling volume levels provided by Pulseaudio devices, but in this case it is possible to configure it at runtime for hooking to ALSA devices like it did in the past.
The required configuration is:
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde/env/kmix_disable_pulse.sh $ chmod +x ~/.kde/env/kmix_disable_pulse.sh
The executable script kmix_disable_pulse.sh
will be started at user's login to alter the default behaviour.
KDE 5
KDE 5.x is currently not officially part of Slackware Linux. It is unofficially provided and mantained by Eric Hameleers, and now it has been configured for using Pulseaudio by default.
For the goals of this guide, the required steps for having it use ALSA as standard output device are the same as for KDE 4.
Please notice that environment startup scripts that in KDE4 were previously placed in ~/.kde/env
must now be placed in ~/.config/plasma-workspace/env
, so in order to configure KMix for ALSA mixer management you will now have:
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.config/plasma-workspace/env/kmix_disable_pulse.sh $ chmod +x ~/.config/plasma-workspace/env/kmix_disable_pulse.sh
Configuration of specific applications
Some of the multimedia software present in Slackware can be configured for using ALSA output or PulseAudio output at run-time, but there is software where the output selection is hardcoded and it can be changed only by means of a recompilation.
All the software that is using KDE's phonon for their output (eg: Amarok) will not require any further changes besides those listed above.
Here is an evolving list of common software and required actions:
mpg123
This software has been compiled for using Pulseaudio as default output but you can change this by simply adding an option on command-line:
$ mpg123 <...> -o alsa <...> file.mp3
Clementine
Clementine audio player requires being compiled with the following cmake options:
cmake \ [...] -DENABLE_LIBPULSE=NO [...]
Sources
* Originally written by LoneStar