Pulseaudio

Pulseaudio in LibreELEC by default only provides sending audio to a bluetooth device. This guide will show you how to setup various audio methods and various pulseaudio related information.

Basically you will be using four commands

used to load a pulseaudio module (not all are loaded by default)

pactl load-module

used to set the pulseaudio output device

pactl set-default-sink

used to set the pulseaudio input device

pactl set-default-source

used to check what the current sink and source devices are

pactl info

sample output

USER
LibreELEC:~ # pactl info Server String: /var/run/pulse/native Library Protocol Version: 31 Server Protocol Version: 31 Is Local: yes Client Index: 41 Tile Size: 65472 User Name: root Host Name: LibreELEC Server Name: pulseaudio Default Sample Specification: s16le 2ch 44100Hz Default Channel Map: front-left,front-right Default Sink: alsa_output.platform-aml_m8_snd.45.analog-stereo Default Source: alsa_input.platform-aml_m8_snd.45.analog-stereo Cookie: c044:1a61

Bluetooth Audio Sending (Default)

Simply pair your bluetooth speaker in the LibreELEC settings add-on

Change your Kodi audio output device to the Bluetooth Audio option.

Play media in kodi

Bluetooth Audio Receiving

Receiving bluetooth audio from a smart phone or other device requires some setup from command line (via ssh).

Simply pair your bluetooth audio device in the LibreELEC settings add-on

Stop kodi (otherwise it will hold onto the audio output device)

systemctl stop kodi

load the pulseaudio udev module

pactl load-module module-udev-detect

Use pactl to find your output device

pactl list short sinks

For example

1	alsa_output.platform-aml_m8_snd.45.analog-stereo	module-alsa-card.c	s32le 2ch 44100Hz	SUSPENDED

Set the output device

pactl set-default-sink alsa_output.platform-aml_m8_snd.45.analog-stereo

Use pactl to find your bluetooth audio device

pactl list short sources

For example

12	bluez_source.B8_53_AC_01_8F_E7	module-bluez5-device.c	s16le 2ch 44100Hz	SUSPENDED

Select the relevant devices as your “source”

pactl set-default-source bluez_source.B8_53_AC_01_8F_E7

Start kodi

systemctl start kodi

Select the audio output device in Kodi (if you want audio from your device and from playing files in Kodi)

Network Audio Sending

Requires another computer/device running pulseaudio! Can be another LibreELEC device.

On a different computer/device that is running pulse audio all you have to do is load the native-protocol-tcp and zeroconf-publish modules

pactl load-module module-native-protocol-tcp auth-anonymous=1
pactl load-module module-zeroconf-publish

Back on the sending device use pactl to find your new output device

pactl list short sinks

For example

39	module-tunnel-sink	server=[[192.168.1.70]]:4713 sink=alsa_output.pci-0000_00_08.0.analog-stereo format=s16le channels=2 rate=44100 sink_name=tunnel.lukas-macbook-pro.local.alsa_output.pci-0000_00_08.0.analog-stereo channel_map=front-left,front-right

Set the output device

pactl set-default-sink tunnel.lukas-macbook-pro.local.alsa_output.pci-0000_00_08.0.analog-stereo

Start kodi

systemctl start kodi

Then select the default pulseaudio device as the audio output device in kodi.

Network Audio Receiving

Requires another computer/device running pulseaudio! Can be another LibreELEC device.

Stop kodi (otherwise it will hold onto the audio output device)

systemctl stop kodi

load the pulseaudio udev module

pactl load-module module-udev-detect

Use pactl to find your output device

pactl list short sinks

For example

1	alsa_output.platform-aml_m8_snd.45.analog-stereo	module-alsa-card.c	s32le 2ch 44100Hz	SUSPENDED

Set the output device

pactl set-default-sink alsa_output.platform-aml_m8_snd.45.analog-stereo

On a different computer/device that is running pulse audio all you have to do is load the native-protocol-tcp and zeroconf-discover modules

pactl load-module module-native-protocol-tcp auth-anonymous=1
pactl load-module module-zeroconf-discover

Back on the first device use pactl to find your new input device

pactl list short sources

For example

38	module-tunnel-source	server=[[192.168.1.70]]:4713 source=alsa_input.pci-0000_00_08.0.analog-stereo format=s16le channels=2 rate=44100 source_name=tunnel.lukas-macbook-pro.local.alsa_input.pci-0000_00_08.0.analog-stereo channel_map=front-left,front-right	

Set the input device

pactl set-default-sink tunnel.lukas-macbook-pro.local.alsa_input.pci-0000_00_08.0.analog-stereo

Start kodi

systemctl start kodi

Adjusting Pulseaudio Server Settings

LibreELEC has a read-only filesystem so /etc/pulse/daemon.conf is not readable by default. Instead we can use the following path.

/storage/.config/pulse-daemon.conf.d

Files have to have the .conf file name extension, but otherwise the file names can be chosen freely. The files under pulse-daemon.conf.d are processed in alphabetical order. In case the same option is set in multiple files, the last file to set an option overrides earlier files. The main daemon.conf file is processed first, so options set in files under pulse-daemon.conf.d override the main file.

nano /storage/.config/pulse-daemon.conf.d/custom.conf

Then add your custom options

resample-method = soxr-vhq
default-sample-format = s16le
default-sample-rate = 44100

To see other resample methods available use the command

pulseaudio --dump-resample-methods

example resample methods

trivial
ffmpeg
auto
copy
peaks
soxr-mq
soxr-hq
soxr-vhq