A friend of mine gave me a nice home made HTPC. I had forgotten the joy of setting up sound and video on Linux. I ended up installing Ubuntu 14.04 LTS with the latest XBMC 13.0 but the part that really was troublesome was to get the sound working.
Turns out PulseAudio tries to be too clever about this, it detected the wrong output. I eventually found a solution on this thread.
In short, edit /etc/pulse/default.pa and added this line:
load-module module-alsa-sink device=hw:1,7
Of course, this will depend on your device, to see what you have, do aplay -l