This page goes into detail on using PulseAudio on Linux systems. PulseAudio is used when Kodi is installed in a desktop-environment rather than a dedicated/direct boot setup. PulseAudio allows normal video & audio playback in XBMC while at the same time allowing the user to get audio in their browser or other applications. It also allows Kodi playback of video or audio to be paused in order to run a game, Skype or similar. Kodi is set to only use PulseAudio if you have installed it and running.
In the past users have experienced problems with audio not working within Kodi, because they were running a full-blown Ubuntu desktop environment with PulseAudio installed. This happened because PulseAudio blocked the device Kodi required, and audio playback only worked reliably when using the virtual Pulse device.
Our workaround for those users has been to uninstall PulseAudio which completely broke desktop audio.
For XBMC 13 'Gotham' and later (named Kodi since 14 'Helix') we wanted this situation to change, so thanks to the new PulseAudio Sink users now can run a normal Ubuntu desktop.
PulseAudio Output Configuration
PulseAudio will be automatically detected and selected in Kodi when it is running.
PulseAudio can be run in one of two modes these are:
Passthrough Mode Used if you want to passthrough (bitstream) AC3, DTS, and EAC3 to an AVR or other device. In order to allow passthrough to work with PulseAudio then it MUST be set to use a 2.0 channel configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.
Used if you want Multichannel PCM out, in this mode you can configure PulseAudio for up to 7.1 channels. In this mode Kodi must decode all audio formats to PCM for passing onto the PulseAudio, this can have the advantage of improve audio/video sync. In the case of video with TrueHD/DTS-HD 7.1 audio this must be decoded by Kodi to Multichannel PCM by disabling passthrough, then Pulseaudio can handle the 7.1 channels of audio.
Setting up pavucontrol
In order to activate passthrough codecs, setup pavucontrol as following:
If you like to do this from the command line, first, first identify the correct sound card ID:
Look at the output to find the id of the card and the name/format of the profile you want to use (in this case, card ID is 0 and profile is output:hdmi-stereo) Once you've identified this information, set your output profile to the one for hdmi-stereo:
pacmd set-card-profile 0 output:hdmi-stereo
Then, obtain the sink ID you want to set formats on by inspecting output of:
pactl list sinks
Then set the sink format for the sink you want, as below (in this case 0):
pactl set-sink-formats 0 "pcm; ac3-iec61937; dts-iec61937; eac3-iec61937"
You can leave out the codecs your AVR does not support, always keep pcm.
To configure instead Multi channel mode, do the following settings.
Example setup in Kodi
No HD Audio (4)
Decode HD Audio (5)
|Pavucontrol - Output Devices|
|Port||Speakers||Speakers||Digital Output (S/PDIF)||Digital Output (S/PDIF)||Digital Output (S/PDIF)||HDMI/Displayport||HDMI/Displayport||HDMI/Displayport|
|Pavucontrol - Configuration|
|Profile||Analog Stereo Output||Analog Surround 5.1 Output||Digital Stereo
|Digital Surround 5.1
|Digital Surround 7.1 |
|Audio Output Device||Speakers||Speakers||SPDIF||SPDIF||SPDIF||HDMI||HDMI||HDMI|
|Number of channels||2.0||5.1||N/A||N/A||N/A||5.1||2.0||7.1|
|Passthrough output device||N/A||N/A||N/A||SPDIF||SPDIF||N/A||HDMI||N/A|
|Dolby Digital (AC3) capable receiver||N/A||N/A||N/A||Enabled||Enabled||Disabled||Enabled||Disabled|
|Enabled Dolby Digital transcoding||N/A||N/A||N/A||Enabled||Enabled||Disabled||Enabled||Disabled|
|DTS capable receiver||N/A||N/A||N/A||Disabled||Enabled||Disabled||Enabled||Disabled|
|TrueHD capable receiver||N/A||N/A||N/A||Disabled||Disabled||Disabled||Disabled||Disabled|
|DTS-HD capable receiver||N/A||N/A||N/A||Disabled||Disabled||Disabled||Disabled||Dsiabled|
(1) Where TV can decode 5.1 AC3.
(2) Where AVR only has SPDIF which will support 5.1 AC3 & DTS.
(3) Where AVR can do 5.1 PCM.
(4) Where AVR has HDMI inputs but can't decode TrueHD or DTS-HD but does support 5.1 Ac3 or DTS.
(5) Where AVR has full decode capabilities including 7.1 PCM.
Combined Output aka dual audio
If you want to output to all your attached devices in parallel, e.g. HDMI out, analog out and USB sound card, it is enough to do as below:
Step 1: Edit
load-module module-combine-sink sink_name=combined
Step 2: Restart pulseaudio.
Kodi will then pickup the device, it is named combined.
Audiophile Pulse User
Pulseaudio resamples everything that does not match the underlaying sink, so if you are an audiophile user, you perhaps want to hear your 96 / 192 khz and 24 bit recordings as exact as possible. Therefore you need to tell pulseaudio to use a better resampler in general and second avoid resampling. Starting with version 11 of pulseaudio, it can reopen sinks with their native samplerate. Furthermore you need to take care, that your sink has a wide enough output format. To properly resample samperates that are not available with your sound card, e.g. 176000 or other exotic rates, we set pulseaudio to a default of 44100 khz, which is the default for every standard mp3. As alternate sample-rate we suggest 48000. That means that all non available samplerates are resampled with an exact integer division of src_rate / dst_rate.
To do this configuration systemwide (96 khz in that example), change /etc/pulse/daemon.conf to include (please replace already existing lines and also remove the commenting):
default-sample-format = s24le default-sample-rate = 44100 alternate-sample-rate = 48000 ;new with pulseaudio 11 avoid-resampling = true resample-method = speex-float-5
Some remark: This will actively make passthrough non working, as we need s16le format for adding ac3 / dts / etc. to the sink.
The last setting will increase the resample quality from pulse and therefore the CPU load quite a lot. Again: Resampling is only done, when the sink output does not match the data you throw onto it. But as most normal mp3s are in 44.1 khz, you need to take great care when upsampling them. The overwriting of the resample-method is for this use case.
When your audio is much too fast or crackles a lot or passthrough only produces noise, you might have a broken driver in use. If this is the case, try to add tsched=0 to the udev loading section in /etc/pulse/default.pa to read like:
load-module module-udev-detect tsched=0
Audio devices are disappearing with pulseaudio 8.0 (Ubuntu 16.04, even later version are affected) especially while running kodi and while using Adjust Refreshrate to match video. This is an issue with the module-switch-on-port-available module and will be fixed with pulseaudio 9.0, the fix sadly won't probably make it into Ubuntu 16.04. As a workaround please disable that feature by editing /etc/pulse/default.pa and commenting or removing load-module module-switch-on-port-available and reboot the system.
When Pulseaudio is configured to be multi-channel output, e.g. 5.1 profile from within pavucontrol, 2.0 streams are automatically upmixed, no matter what setting you have chosen in Kodi. This is default pulseaudio server behaviour. You can workaround that by disabling enable-remixing in /etc/pulse/daemon.conf
enable-remixing = no
Beware: This will also forbid PA to remix e.g. FL,FR, LFE, FC, BL, BR into FL, FR, LFE, FC, SL, SR - which means you might loose your rears if your speaker layout is non standard.
Starting with the upcoming kodi v17 Krypton the above behaviour is taken care within kodi. You don't have to disable remixing in pulseaudio anymore. That means content is output without further remixing by pulseaudio server if a sane mapping is possible. Basically that means if the audio is FL, FR, FC, LFE, SL, SR and your speaker-mapping is FL, FR, FC, LFE, BL, BR we will resolve that and output 6 channels accordingly. Whenever we cannot map all input channels to the output we ask pulseaudio to do the mixing for us.
Issue: Changing kodi's volume will change overall system volume, especially on song change this is an irritating behaviour. The effect you hear is not done by kodi, but by a systemwide pulseaudio (mis)configuration. Some distributions sadly still ship pulseaudio with flat-volumes = yes as the default, which produces this behaviour. In fact it will cause the hardware volume (or master volume) to go up and down for every pulseaudio stream that changes its own volume. As this effect is unexpected behaviour for users, distributions started to ship pulseaudio with flat-volumes = no by default (as time of writing this is Ubuntu, Arch-Linux and others). In order to change that setting, depending on your distribution edit /etc/pulse/daemon.conf and set flat-volumes = no. After a PA server restart, the volume handling is more intuitive. If you are at it, please inform your distribution about those issues, so that they can ship a more user-friendly default with next release. At the time of writing, affected distributions: Debian.