Difference between revisions of "PulseAudio"

From Official Kodi Wiki
Jump to: navigation, search
m
Line 1: Line 1:
 
{{Gotham}}
 
{{Gotham}}
 
{{Audionav}}
 
{{Audionav}}
__NOTOC__
 
  
 
In the past users have experienced problems with audio not working within XBMC, because they were running a full-blown Ubuntu desktop environment with PulseAudio installed. This happened because PulseAudio blocked the device XBMC required, and audio playback only worked reliably when using the virtual Pulse device.
 
In the past users have experienced problems with audio not working within XBMC, because they were running a full-blown Ubuntu desktop environment with PulseAudio installed. This happened because PulseAudio blocked the device XBMC required, and audio playback only worked reliably when using the virtual Pulse device.
Line 16: Line 15:
  
 
<big>'''Passthrough Mode'''</big>
 
<big>'''Passthrough Mode'''</big>
 
 
Used if you want to passthrough (bitstream) AC3, DTS, and EAC3 to an AVR or other device. In order to allow passthrough the PulseAudio '''MUST''' be set to use 2.0 channels configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.
 
Used if you want to passthrough (bitstream) AC3, DTS, and EAC3 to an AVR or other device. In order to allow passthrough the PulseAudio '''MUST''' be set to use 2.0 channels configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.
  
'''Note -''' Systems with PulseAudio will not work with TrueHD or DTS-MA passthrough.
+
{{Note| Systems with PulseAudio will not work with TrueHD or DTS-MA passthrough.}}
  
 
<big>'''Multichannel Mode'''</big>
 
<big>'''Multichannel Mode'''</big>
Line 25: Line 23:
 
Used if you want Multichannel PCM out, in this mode you can configure PulseAudio for up to 7.1 channels. In this mode XBMC must decode all audio formats to PCM for passing onto the PulseAudio, this can have the advantage of improve audio/video sync.
 
Used if you want Multichannel PCM out, in this mode you can configure PulseAudio for up to 7.1 channels. In this mode XBMC must decode all audio formats to PCM for passing onto the PulseAudio, this can have the advantage of improve audio/video sync.
  
'''Note -''' TrueHD can be decode by XBMC to PCM 7.1 but when passing through PulseAudio the audio will not be "bit perfect". In this mode DTS-HD can't be decoded to PCM 7.1 only the core DTS 5.1 track can be decoded to PCM 5.1.
+
{{Note| TrueHD can be decode by XBMC to PCM 7.1 but when passing through PulseAudio the audio will not be "bit perfect". In this mode DTS-HD can't be decoded to PCM 7.1 only the core DTS 5.1 track can be decoded to PCM 5.1.}}
 
<br />
 
<br />
  

Revision as of 13:24, 19 March 2014

Future.png GOTHAM FEATURE:
This page or section describes features that were added as a part of XBMC v13 with codename "Gotham".
Audio Table of Contents
General Audio Help: OS Configuration Help:

In the past users have experienced problems with audio not working within XBMC, because they were running a full-blown Ubuntu desktop environment with PulseAudio installed. This happened because PulseAudio blocked the device XBMC 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 we wanted this situation to change, so thanks to the new PulseAudio Sink users now can run a normal Ubuntu desktop.

The PulseAudio Sink 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 XBMC playback of video or audio to be paused in order to run a game, Skype or similar. XBMC only uses PulseAudio in case you have installed it and it is running.

1 Multichannel Output Options

PulseAudio will be automatically detected and selected in XBMC when it is running.

PulseAudio can be run in 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 the PulseAudio MUST be set to use 2.0 channels configuration, despite the 2.0 setting this will still allow 5.1 audio from AC3, DTS, and EAC3.

Note: Systems with PulseAudio will not work with TrueHD or DTS-MA passthrough.

Multichannel Mode

Used if you want Multichannel PCM out, in this mode you can configure PulseAudio for up to 7.1 channels. In this mode XBMC must decode all audio formats to PCM for passing onto the PulseAudio, this can have the advantage of improve audio/video sync.

Note: TrueHD can be decode by XBMC to PCM 7.1 but when passing through PulseAudio the audio will not be "bit perfect". In this mode DTS-HD can't be decoded to PCM 7.1 only the core DTS 5.1 track can be decoded to PCM 5.1.

2 Setting up pavucontrol

2.1 Passthrough Mode

IMPORTANT: Passthrough is always exclusive mode. If you have another application hogging the device, e.g. google chrome or skype or something else, Passthrough won't work.
REMEMBER: To use passthrough you need to be using 2.0 channel configuration via pavucontrol (e.g. Digital Stereo (HDMI)


In order to activate Passthrough Codecs, just setup pavucontrol, as in the following:

If you like to do this from the command line, issue:

pactl set-sink-formats 0 "pcm; ac3-iec61937; dts-iec61937; eac3-iec61937"

Where 0 is the sink you want to alter. You can print all sinks, by using:

pactl list sinks

You can leave out the codecs your AVR does not support, always keep pcm.

IMPORTANT: If you have for example 5.1 flacs or other multichannel files, you can play them as AC3 streams, check the AC3 Transcoding setting.


2.2 Multichannel Mode

REMEMBER: When configuring pulse to use Multichannel configuration passthrough will be disabled

To configure instead Multi channel mode, do the following settings.

2.3 Example setup in xbmc

GOOD TO KNOW: Limit sample rate can be set to Fixed - between 48kHz ~ 192kHz or as Optimized and even Best match.



2.4 Guide setup in xbmc

DEVICE ENUMERATION: XBMC Enumerates Pulseaudio devices as SPDIF when you have Passthrough set. Otherwise its PCM Device.
GOOD TO KNOW: SPDIF has 2 pcm channels but can do virtual 5.1 formats like dts, ac3, eac3.


Editor note: This part could do with a once over to make it clearer that 5.1 virtual channels from the 2.0 pcm channels spdif is capable is ok with passtrough, while when setting up pvacontrol to 5.1/7.1 then as below xbmc settings applies

XBMC Settings PC Speakers
(2.0)
PC Speakers
(5.1)
TV AVR SPDIF AVR HDMI
AVR HDMI
★★
SPDIF
AC3 support
Audio Output Analog Analog Analog Optical/Coaxial HDMI HDMI SPDIF
Channel number 2.0 5.1 2.0 2.0 5.1 7.1 2.0
Boost volume level on downmix Enabled Enabled Enabled Enabled Enabled Enabled Enabled
Stereo upmix Disabled Disabled Disabled Disabled Enabled Enabled Enabled
Dolby Digital (AC3) capable receiver N/A N/A N/A Enabled Disabled Disabled Enabled
Dolby Digital Plus (E-AC3) capable receiver N/A N/A N/A Enabled Disabled Disabled Enabled
DTS capable receiver N/A N/A N/A Enabled Disabled Disabled Enabled
TrueHD capable receiver N/A N/A N/A Disabled Disabled Disabled Disabled
DTS-HD capable receiver N/A N/A N/A Disabled Disabled Disabled Disabled
Linux / OSX - Output Device Settings
Audio output device Speakers Speakers SPDIF/HDMI SPDIF HDMI HDMI SPDIF
Passthrough output device N/A N/A N/A SPDIF HDMI HDMI SPDIF

Passthrough cannot be selected when Multichannel is enabled...

★★ Passthrough cannot be selected when Multichannel is enabled...

IMPORTANT: You can only have AC3, DTS, EAC3 passthrough if your Receiver supports it. Most TV's only support AC3. If you have a HDMI connection to your TV and from this TV a SPDIF/Optical connection to an AVR, passthrough might not work at all.


3 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 /etc/pulse/default.pa

load-module module-combine-sink sink_name=combined

Step 2: Restart pulseaudio.

killall pulseaudio

xbmc will then pickup the device, it is named combined.

4 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 change the default sample rate to 96 or 192 khz. Pulseaudio does not resample audio, that is already in the correct samplerate. Furthermore you need to take care, that your sink has a wide enough output format.

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 = s32le 
default-sample-rate = 96000
resample-method = speex-float-5

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.

Alternatively: If you don't want any resampling outside xbmc, e.g. no resampling done extra by pulse, you need to configure the sink as told above and set Audio Engine to Fixed with the number of channels you configured pulseaudio via pavucontrol and samplerate of 96 khz with resample quality high. In that combination xbmc will take care that files are resampled (e.g. 44.1 khz or 48 khz media) in the best possible quality. Already 96 khz files are not touched at all.


5 FAQ

5.1 When would I want Pulseaudio?

Link

You should use pulseaudio when:

  • You use your XBMC computer mainly as your Desktop when you don't run XBMC.
  • You want other applications audio like Skype, youtube, browser mail notification in parallel with XBMC.
  • You use xbmc in windowed mode as Desktop player
  • You use Pulseaudio as a network sink to stream Audio to other devices in your living room.
  • Passthrough is nice to have for you, but to be honest - you don't really need it.
  • Whenever you plugin your Bluetooth headset, xbmc audio will continue over this new device (when Default 'PULSE' device is chosen)

5.2 When would I want ALSA?

Link

You should use alsa when:

  • You use XBMC as your standalone media center.
  • You are highly interested in bitperfect exclusive audio output.
  • DTS-HD, TrueHD is something you use daily and is of high importance.
  • You don't need other applications that would access audio in parallel.

5.3 Why can't I have both?

Link
  • Pulseaudio might hog your Audio device and you cannot open the ALSA device exclusively, therefore we decided for one or the other.

5.4 Can I force ALSA even with pulseaudio installed?

Link

Note: But you know that doing so, it will cause problems!

Yes, you can - start xbmc from terminal with:

AE_SINK=ALSA xbmc
- Be warned as this might interfere with your Desktop sounds and pulseaudio!

5.5 Known issues

Whenever the Pulseaudio Sink is unloaded, the stream is completely destructed and created newly. This will reset the stream's volume to the internal xbmc volume. This is only an issue if you use "external volume", e.g. you use pavucontrol and change the stream volume via slider. This only affects the current running stream as xbmc gets no knowledge about it. Best is: use xbmc's internal volume or change the global volume only.

5.6 References

Attention talk.png Linux - Pulseaudio Sink Discussion and further information.