Pulse

From Jon's Wiki

If you have spent days and days fucking around trying to get sound to work with your NVidia 220GT HDMI, you have to use hw:0,7 (not hw:0,3 which is, it turns out, the first AND ONLY thing Pulse sees), and then you need to unmute it in ALSA.

sudo apt-get install alsamixergui

Run alsamixergui and UNMUTE ALL FOUR SPDIF CHANNELS. It was apparently decided that leaving them muted by default was the sensible and least frustrating thing to do.

Support for 24 bit 96 kHz audio

Make Pulse use 32 bit samples in /etc/pulse/daemon.conf and bump up the sample rate:

default-sample-format = s32le
default-sample-rate = 96000

Surround sound

Since I have a surround HDMI amplifier, I use this in /etc/pulse/default.pa after the autodetect phase (which you might still want for when you plug in USB devices, for instance):

load-module module-alsa-sink device=hw:0,7 channels=6 \
  channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe

and in /etc/pulse/daemon.conf you need:

default-sample-channels = 6
default-channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe

Dolby Digital and DTS "pass-through" streaming

There isn't currently a way to pipe the Dolby Digital or DTS streams directly to the amplifier without abandoning Pulse altogether and reverting to ALSA. However, these days decoding even 24/96 surround in Pulse uses pretty negligible CPU, and pass-through ALSA blocks the audio device anyway. This way also means you can enjoy all those annoying alarms, random pop-up beeps and messaging alerts while you watch your movies.