Thanks for the tip, I have always used ALSA, (removed pulseaudio) but this is problematic because I have no sound outside of Kodi. I tried to use the ALSA sink when running pulse audio. This works but it have the side effect on my setup, that I can't figure out. I am running Ubuntu 14.04 LTS. It is hooked up to a AVR that support DTS ma etc.

If I run the AE_SINK=ALSA kodi from the terminal or use it in a .desktop file it works perfectly pushing the dts-ma out to the AVR, even when pulse audio is the default. This is good :)

The problem I am facing is in conjunction with xautomation and lirc My setup is a bit complex because I use a harmony to control everything.

This is extremely smart, because it makes it wife proof :) she can't hit one button and both TV, AVR, PC, speakers start on the correct channels. and she can control a fully fledged PC as was it a smart TV.

SIMEREC pcs2 is installed in the media center to control on/of via hw switch. But from within Ubuntu it uses xautomation and lirc to make things happen.

This add the feature to script everything like starting Kodi, closing Kodi, navigation in the system. Because this is its own service, if something freezes or crashes, with a push of one button Kodi is force closed and started again. you can also force restart the desktop environment, but this is rarely a problem. I have used this setup since LTS 12.04

The side effect I am experiencing is when I set the parameter AE_SINK=ALSA kodi on the .desktop file or I the startup script and uses xautomation to execute it. This makes irexec crash. When I try to restart irexec -d the service don't start. Until I remove AE_SINK=ALSA line

Not Working:

#!/bin/bash killall -9 kodi.bin AE_SINK=ALSA kodi &

Working: