One problem I have had with my new Dell PowerEdge server/workstation [1] is that sound doesn’t work correctly. When I initially installed it things were OK but after installing a new monitor sound stopped working.
The command “aplay -l” showed the following:
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Speaker [Logitech USB Speaker], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
So the HDMI sound hardware (which had no speakers connected) became ALSA card 0 (default playback) and the USB speakers became card 1. It should be possible to convert KDE to use card 1 and then have other programs inherit this, but I wasn’t able to configure that with Debian/Wheezy.
My first attempt at solving this was to blacklist the HDMI and motherboard drivers (as suggested by Lindsay on the LUV mailing list). I added the following to /etc/modprobe.d/hdmi-blacklist.conf:
blacklist snd_hda_codec_hdmi
blacklist snd_hda_intel
Blacklisting the drivers works well enough. But the problem is that I will eventually want to install HDMI speakers to get better quality than the old Logitech portable USB speakers and it would be convenient to have things just work.
Jason white suggested using the module options to specify the ALSA card order. The file /etc/modprobe.d/alsa-base.conf in Debian comes with an entry specifying that the USB driver is never to be card 0, which is exactly what I don’t want. So I commented out the previous option for snd-usb-audio and put in the following ones to replace it:
# make USB 0 and HDMI/Intel anything else
options snd-usb-audio index=0
options snd_hda_codec_hdmi=-2
options snd_hda_intel=-2
Now I get the following from “aplay -l” and both KDE and mplayer will play to the desired card by default:
**** List of PLAYBACK Hardware Devices ****
card 0: Speaker [Logitech USB Speaker], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
Yeah, I’ve done something like that on most computers I’ve configured in last 5 or so years. But it’s wrong. Or can you imagine Joe Random User fiddling with module parameters? I was never quite able to get the correct way to work though.
ALSA has a powerful config file. The config file defines device called `default` and all applications by default use that for playing. So it _should_ be just a matter of defining what is a default device. Unfortunately when I tried on the last computer, I couldn’t get it to work properly. When I used `pcm.default { type hw; card 1,0 }` (or similar), it played on the correct card, but multiplexing stopped working and when I tried with `type plughw` it stopped working with non-default rates (apparently doing the multiplexing in software when the hardware supports it just fine). So I gave up and reordered the devices with module parameters again.
But I still think it _should_ be possible. The default device is not built in, it is defined by the default configuration. It would just need somebody who would actually understand that beast. Than we could add capability of writing appropriate configuration file to the KDE sound configuration module and finally Joe Random User would be able to switch sound cards.
PS: looking at the default configuration file (`/usr/share/alsa/alsa.conf`) it seems like `defaults.ctl.card 1; defaults.pcm.card 1` might do the trick.