Archive for March 29th, 2009

Making ALSA Sort Multiple Sound Cards Properly

Multiple sound cards pose a problem for ALSA, because they don’t appear in the same order on every boot. This is particularly true for hotplugged USB stuff, but it can also affect PCI and system board audio devices.

The symptom is that you suddenly don’t hear any sound. The reason is that ALSA is dutifully piping sound through the card that’s not connected to your speakers.

The fix is straightforward, if not at all obvious: force the proper card to be Card 0, then force the ALSA default PCM output to use that card. Either should work alone, but both together will enforce the decision.

Find out which drivers are in use:

cat /proc/asound/cards
 0 [AudioPCI       ]: ENS1371 - Ensoniq AudioPCI
                      Ensoniq AudioPCI ENS1371 at 0xb8c0, irq 16
 1 [Headset        ]: USB-Audio - Logitech USB Headset
                      Logitech Logitech USB Headset at usb-0000:00:1d.3-1, full speed
 2 [Intel          ]: <strong>HDA-Intel</strong> - HDA Intel
                      HDA Intel at 0xfebfc000 irq 16

The system-board sound hardware uses the HDA-Intel driver, which should be Card 0 and the default sound output.

Add this to the bottom of /etc/modprobe.d/alsa-base, prefixing the module name from the /proc/asound/cards list with snd-

#--- hack to get sound ordering correct
options snd-hda-intel index=0

Find out what ALSA thinks is possible:

aplay -L
 ... snippage ...
    HDA Intel, STAC92xx Analog
    Front speakers
 ... snippage ...

Create /etc/asound.conf (because it’s not created by default) and add this, using the name from the appropriate CARD= entry:

# Hack to order the cards correctly
pcm.!default front:Intel

This is one of those gotta-reboot events, because removing & reinstalling modules, then restarting ALSA, just isn’t worth the effort for a single-user desktop box.

Update: Except that sometimes it still doesn’t work. The dmesg report shows

[   36.779814] ENS1371 0000:05:04.0: PCI INT A -> GSI 16 (level, low) ->IRQ 16
[   36.922744] cannot find the slot for index 0 (range 0-0), error: -16
[   36.922808] hda-intel: Error creating card!
[   36.924631] HDA Intel: probe of 0000:00:1b.0 failed with error -12

From which I infer that the Ensoniq card gets polled first, grabs slot 0, and then the Intel driver can’t get a word in edgewise.

Next step: another line at the bottom of /etc/modprobe.d/alsa-base:

options snd-ens1371 index=2

Update: You’ll probably find that Adobe Flash still plays through the wrong audio device. There’s no obvious was to reconfigure it, so just blow away its own setup and let it start over with the audio cards sorted properly:

cd ~
rm -rf .adobe/Flash_Player
rm -rf .macromedia/Flash_Player

Those of long memory will recall that Macromedia cooked up Flash before getting Borged by Adobe.

While you’re under the hood, turn off Flash cookies.


Leave a comment