Just a small addition to this if someone else wants to do the same..
In order to use pulseaudio with HDMI audio out on server image these lines need to be in the /etc/pulse/default.pa:
load-module module-udev-detect tsched=0 # Just add 'tsched=0' at the end of the existing line
set-default-sink alsa_output.platform-sndhdmi.analog-stereo # Use HDMI as Pulseaudio's default audio sink
To use plain Alsa these should be in the /etc/asound.conf:
ctl.!default {
type hw
card 1 # card 1 is the HDMI output
}
pcm.!default {
type plug
slave {
pcm "hw:1,0"
rate 48000 # Upsample all output to 48kHz as HDMI seems to support only 44.1kHz or 48kHz
channels 2
format S16_LE
}
}