Penguin

See also Alsa5.1Notes.

Application support for ALSA

  • There is a version of esd(1) that uses ALSA – that means that any app that currently uses esd(1) will be fine. (In Debian the Package is called libesd-alsa0.)
  • ALSA has optional support for OSS compatibility for older apps that only know about the OSS-style sound drivers. To use it, make sure the snd-pcm-oss module is loaded. (In Debian, you can just set startosslayer=true in /etc/default/alsa for the startup scripts to do this for you.)

Module hints

  • It may be a good idea to make sure you have the snd-pcm-oss module if you want backwards-compatibility for older apps (see further below). If you are compiling the modules from source, include --with-oss=yes on your ./configure line.
  • The sound-card on a Thinkpad 600E needs the snd-cs4236 module, despite the card claiming to be a 46xx (and using a module named cs4232 in the older OSS driver series).

My sound card doesn't work after an upgrade

Run alsaconf, it will probably fix it.

Not all sound devices work

If one of your sound devices doesn't work and you get an error similar to EMU10K1_Audigy: probe of 0000:02:0a.0 failed with error -12 then it might be because the devices are fighting over which sound card number they want to be. To fix this alter the sound card module options (see Module page on how to do this). One example of a configuration that works is options snd-emu10k1 index=-15. The index parameter specifies which card becomes which number, or if negative then it is a bitmask of numbers that it can be autoassigned to. To learn more about this look at the LinuxKernel source file Documentation/sound/alsa/ALSA-Configuration.txt

Software Mixing With ALSA

You can get ALSA to do software mixing for you without having to resort to something like esd(1). This is done via the dmix plugin and as documented on the ALSA wiki. As of 1.0.9rc2, this is configured out of the box for the vast majority of consumer sound chipsets. (The first Ubuntu version to benefit from this was Breezy.)

If you have an earlier version, after you get ALSA going, you need to put the following in a .asoundrc file in your home directory.

# .asoundrc file. Put this in your home directory.

pcm.mixed {
    type dmix
    ipc_key 123456 # Any unique value
    ipc_key_add_uid true # No idea...
    slave {
        pcm "hw:0,0"
        # Apparently for OSS emulation device, you have to set the period
        # and the buffer sizes in powers of two.
        period_time 0
        period_size 1024  # must be power of 2
        buffer_size 4096  # ditto
        rate 44100
    }

    # bindings are cool. This says, that only the first
    # two channels are to be used by dmix, which is enough for
    # (most) oss apps and also lets multichannel chios work
    # much faster:

    bindings {
        0 0   # from 0 => to 0
        1 1   # from 1 => to 1
    }
}

pcm.!default {
    type plug
    slave.pcm mixed
}

pcm.dsp0 {
    type plug
    slave.pcm mixed
}

pcm.mixer0 {
    type hw
    card 0
}

There are some problems with this. First of all, OSS Kernel emulation won’t go through this layer. For an OSS-based application to use this, you need to use the aoss helper utility. Also, for SDL based applications (usually games) to use this, you will want the EnvironmentVariable AUDIODEV to be set to default, ie. export AUDIODEV=default.

Surround-Sound Notes

Couple of pages that might be useful, at the ALSA Wiki and Halfgaar, thanks to Dave Phillips.

Soundblaster SB16 module

On my LinuxKernel2.6 system, I couldn't load the ALSA module for the ISA SB16 card, no matter what I did. Eventually, I discovered it loaded fine if I disabled the isapnp option for the module. Eg in /etc/modprobe.conf, I had

options snd-sb16 isapnp=0

It seemed to be defaulting to trying to use isapnp but that didn't work, whether or not I enabled Kernel ISA PnP support and BIOS PnP support.

modprobe(8) complains about unresolved symbols in schedule_work

You need to run touch include/linux/workqueue.h between ./configure and make on alsa-driver.

If you want to do this while building from SRPM, do the following:

Install the SRPM:

rpm -ivh alsa-driver.x.y.z-p.src.rpm

Now open the alsa-driver.x.y.z-p.spec in the SPECS/ directory, locate the %configure and make commands and add the following command between them:

touch include/linux/workqueue.h

Finally, RPM needs to be told to build the spec file:

rpmbuild -bb --define 'cards als4000' --target $arch \
    alsa-driver.x.y.z-p.spec

You can now install the RPMs built in the RPMS/$arch/ directory.

Compiling ALSA on RedHatLinux using the FreshRpms SRPM

You probably want to set up your own <tt>.rpmmacros</b> file first, as per RPMNotes. Remember to specify the target architecture and the card (see the ALSA soundcard matrix to find yours) to compile for, eg.:

rpmbuild --rebuild alsa-driver.x.y.z-p.src.rpm \
    --define 'cards als4000' --target $arch

where $arch might be athlon, f.ex. The RPMs will end up in RPMS/$arch/, ie f.ex in RPMS/athlon/. As with all source builds, you will need to recompile the SRPM if you upgrade your Kernel; you only need to install the kernel-module-alsa RPM, however.

See also

ALSA configuration notes