How to make PulseAudio work with Nvidia HDMI audio outputs under Fedora and Ubuntu

March 25, 2011

Normally the sound setup for my machine consists of a pair of Wharfedale speakers and a Temple Audio Bantam XC2 amplifier. Due to the fact I’ll be returning home later this morning for my final Easter vacation, pretty much everything I have is packed up in boxes right now; the machine and screen remain on the desk, however. Driven by the desire to listen to music while I finished packing, I decided to get output over HDMI working (having had problems with it in Fedora [14] and Ubuntu [10.10] in the past). I have an iiyama monitor which has speakers built in and is connected to a GTX 470 graphics card by HDMI.

The problem was that although the PulseAudio Volume Control applet (pavucontrol) showed the output (as “G100 High Definition Audio Controller (HDMI)”), when I redirected output streams to the device I simply heard no sound. As I didn’t have this problem under Windows I knew it was a software issue.

After some more experimentation using aplay I figured out that the problem was due to PulseAudio outputting to the wrong HDMI subdevice. This I did by running aplay -l:

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC889 Analog [ALC889 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC889 Digital [ALC889 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: NVIDIA HDMI [NVIDIA HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0

I then tested out each subdevice to determine which actually produced sound:

aplay -D hw:1,3 testsound.wav
aplay -D hw:1,7 testsound.wav
aplay -D hw:1,8 testsound.wav
aplay -D hw:1,9 testsound.wav

I found that 7, 8 and 9 would produce sound while 3 did not. Assuming the problem was that PulseAudio was using 3, I set about changing that:

  1. Open /etc/pulse/default.pa
  2. Find the line load-module module-udev-detect and comment it out with a #
  3. Paste in at the end of the file entries that will manually load the necessary modules for your hardware. In my case: load-module module-alsa-sink device=hw:1,7
    load-module module-alsa-sink device=hw:0,0 (necessary so I can also use the Wharfedale speakers, since it will no longer be autoloaded).

Having done this a simple killall pulseaudio was enough to make things work; I could resume Spotify playback and then redirect it successfully to the iiyama speakers using pavucontrol. One problem that came about was that the volume hotkeys on my keyboard stopped having any effect on actual audio volume as they weren’t being mapped to the right sink. Before I got a chance to look into it more I’d had to reboot the machine to move some cables, and this turned out to be enough. Perhaps even just logging out and back in again would have been sufficient.

Hopefully this guide will help a few people; I came across plenty of posts by people having the same problem when I Googled it but no solutions.

Notes:

  1. The system I did this on is running Fedora 14. As such I haven’t actually tested the solution on Ubuntu 10.10, but I know that the same problem exists from when this machine ran Ubuntu.
  2. It may be necessary to unmute the HDMI output channels using alsamixer (press F6 when in alsamixer to change device, press m to toggle mute/unmute status).