HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio
#1
I use a vanilla Ubuntu desktop distro on my HTPC and  use Chrome etc to watch iPlayer/catchup services however all the desktop services that use audio depend on pulseaudio, and the other workarounds like setting up a new sink - KODI_AE_SINK=ALSA to allow audio passthrough  didn't work for me so I worked out an alternative approach with a simple script that -
Stops pulseaudio from respawning, stops pulseaudio from listening for tcp connections - since Kodi itself will trigger it to start!, finally kill any already spawned pulseaudio threads.
At this point Kodi will launch and audio will use your configured passthrough device, and any codecs you have enabled will also be passed through to your external device, AV Amp etc.
Upon exiting Kodi the script then restores and restarts pulseaudio so that normal desktop audio still works.
Note: this obviously means that whilst Kodi is launched no other applications that depend on pulseaudio will be able to generate audio
Here's the script -

#!/bin/bash
DISPLAY=:0.0
echo autospawn=no > $HOME/.config/pulse/client.conf      # prevent autospawn
systemctl --user mask pulseaudio.socket      # stop it listening on sockets
systemctl --user stop pulseaudio             # stop the daemon
killall pulseaudio                           # stop any spawned threads
kodi                                         # launch Kodi
systemctl --user unmask pulseaudio.socket    # start listening
systemctl --user start pulseaudio            # start the daemon
rm $HOME/.config/pulse/client.conf           # allow daemon to spawn on-demand

The DISPLAY line is present to allow true headless operation where I want to play music remotely using Kore with my TV turned off

I hope this is of use to someone in the community
Reply
#2
Oops - missed the export off the DISPLAY line, it should read - 

export DISPLAY=:0.0
Reply



Logout Mark Read Team Forum Stats Members Help
HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio0
This forum uses Lukasz Tkacz MyBB addons.