Kodi Community Forum
HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio (/showthread.php?tid=355302)



HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio - hacker1 - 2020-06-19

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


RE: HowTo Kodi with passthrough on a regular Linux distro that uses pulseaudio - hacker1 - 2020-06-19

Oops - missed the export off the DISPLAY line, it should read - 

export DISPLAY=:0.0