ALSA

From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.
Some of the information in this article may have drifted out of sync with current practices. Please help out by checking over the content (how to get started).


ALSA, the Advanced Linux Sound Architecture, is the Linux kernel's API for sound cards, together with an associated software framework. Sound servers such as PipeWire, PulseAudio, and JACK all function as a layer on top of ALSA. ALSA can be used directly, without a sound server; however, sound servers provide various additional conveniences and functionality.

As of 2026-01-14, desktop profiles enable the PipeWire sound server. This includes support for packages which make use of the PulseAudio interface (e.g. via the pulseaudio USE flag), by using media-sound/libpulse and pipewire-pulse(1).

Those using PipeWire as a sound server - whether via a profile or otherwise - should typically not need to manually configure ALSA. However, those with more complex hardware and software setups might need to do so.

This page assumes that no sound server is being used.

Installation

Hardware detection

Important
To check if a system has working soundcard driver modules, run lsmod(8). If that lists no modules with the prefix snd_, be sure that the kernel driver module for the system's specific soundcard is installed. Refer to the Kernel Modules page for details.

To choose the right driver, detect the audio controller in use, via lspci:

user $lspci | grep -i audio

The needed driver can then be found in the ALSA sound card matrix.

Kernel

Activate the following kernel options:

KCONFIG
 General setup --->
   -*- System V IPC Search for <code>CONFIG_SYSVIPC</code> to find this item.
 Device Drivers --->
   <*> Sound card support Search for <code>CONFIG_SOUND</code> to find this item. --->
     <*> Advanced Linux Sound Architecture Search for <code>CONFIG_SND</code> to find this item. --->
       [*] PCI sound devices Search for <code>CONFIG_SND_PCI</code> to find this item. --->
         <Select the audio controller driver(s) for the system's audio controller(s)>
       HD-Audio --->
         <Select a codec or enable all and let the generic parse choose the right one>
         [*] ...
       [*] USB sound devices Search for <code>CONFIG_SND_USB</code> to find this item. --->
         <Must have as some cards are presented as USB devices>
         [*] USB Audio/MIDI driver Search for <code>CONFIG_SND_USB_AUDIO</code> to find this item.

If the system has more than eight sound outputs (note that each HDMI output on a GPU counts as an output), the maximum number of sound cards will need to be increased:

KCONFIG
 Device Drivers --->
   <*> Sound card support Search for <code>CONFIG_SOUND</code> to find this item. --->
     <*> Advanced Linux Sound Architecture Search for <code>CONFIG_SND</code> to find this item. --->
       -*- Dynamic device file minor numbers Search for <code>CONFIG_SND_DYNAMIC_MINORS</code> to find this item.
       (32) Max number of sound cards Search for <code>CONFIG_SND_MAX_CARDS</code> to find this item.

Kernel modules

For advanced configurations (e.g. involving multiple sound cards), it can be better to select all the ALSA-related kernel options as modules. Then, their use can be configured via two files:

  • /etc/modules-load.d/alsa.conf - one line per module, normally only needed for virtual sound cards.
  • /etc/modprobe.d/alsa.conf - for the modules' options.

For example, assume a laptop with two hda-intel sound cards and an external USB card. If the aloop and VirMIDI virtual sound cards are also required, together with a card order that persists across reboots:

  1. the aloop virtual card
  2. the hda-intel PCM device
  3. the hda-intel HDMI device
  4. the VirMIDI virtual device
  5. the USB card

then the relevant modules should be loaded in that order:

FILE /etc/modprobe.d/alsa.conf
options snd slots=snd-aloop,snd-hda-intel,snd-hda-intel,snd-virmidi,snd-usb-audio
options snd-hda-intel index=1,2 model=1002:1637,1022:15e3

Card indexes start from 0.

To get the model strings, use lspci(1) (or lsusb(1) for USB cards):

root #lspci -nn
04:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Renoir Radeon High Definition Audio Controller [1002:1637]
04:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller [1022:15e3]

Instruct the kernel to load the virtual sound cards:

FILE /etc/modules-load.d/alsa.conf
snd-aloop
snd-virmidi

Software

Enabling the alsa global USE flag will not only enable support for ALSA packages, but will also automatically pull in media-libs/alsa-lib. The alsa USE flag is enabled by default in the x86 and amd64 desktop profiles.

After enabling the flag, update the system so the changes take effect:

root #emerge --ask --changed-use --deep @world

The media-sound/alsa-utils package provides some tools for troubleshooting and testing the sound system. It's a good idea to merge the package if it's not already installed:

root #emerge --ask media-sound/alsa-utils

Commands provided by media-sound/alsa-utils include:

Name Description
aconnect(1) ALSA sequencer connection manager
alsactl(1) Advanced controls for ALSA soundcard driver
alsamixer(1) Soundcard mixer for ALSA soundcard driver, with ncurses interface
amixer(1) Command-line mixer for ALSA soundcard driver
aplay(1) Command-line player for ALSA soundcard driver
aplaymidi(1) Play Standard MIDI Files
arecord(1) Command-line sound recorder for ALSA soundcard driver
aseqdump(1) Show the events received at an ALSA sequencer port
speaker-test(1) Command-line speaker test tone generator for ALSA

Configuration

Files

The 'root' of ALSA configuration is the /usr/share/alsa/alsa.conf file. By default, this file specifies several locations for ALSA configuration files:

  • /var/lib/alsa/conf.d/
  • /usr/etc/alsa/conf.d/
  • /etc/alsa/conf.d/
  • /etc/asound.conf or /usr/etc/asound.conf
  • ~/.asoundrc
  • ${XDG_CONFIG_HOME}/alsa/asoundrc

Configuration locations later in the list override earlier ones. If the XDG_CONFIG_HOME environment variable is not set, it's given a default value of ~/.config/.

/etc/asound.conf is typically used as the global (system-wide) configuration file, while ~/.asoundrc is typically used as a local (per-user) configuration file, overriding ALSA configuration for a specific user. Neither file exists by default; each must be created manually as necessary.

This page refers to both /etc/asound.conf and ~/.asoundrc when describing configuration snippets, but the snippets can typically be added to either file (or to another location), depending on the specific configuration being sought. For example, one particular snippet might be most appropriately applied system-wide, or might be most appropriately applied per-user.

A description of the syntax for ALSA configuration files is available in /usr/share/doc/alsa-lib-<version>/asoundrc.txt.gz.

Various configuration snippets are available in the /usr/share/alsa/, the global configuration directory. For example, snippets available in the /usr/share/alsa/pcm/ directory include dmix.conf, hdmi.conf, and surround51.conf.

Creating a configuration

In general, ALSA should work "out of the box", and not require any manual configuration. To list the current ALSA configuration, including any configuration files being applied, use the command alsactl dump-cfg. Additionally, ALSA's current state can be listed by using the command alsactl dump-state; ALSA state is stored in, and restored from, /var/lib/alsa/asound.state.

If a system has special hardware, the defaults of card 0 and device 0 might not work. However, on a system with multiple sound cards, cards might be reordered across boots; thus, specifying a card by its index number might prevent sound from working properly.

Internally, the card number is a name, which can be listed by passing the -L option to aplay(1), from the media-sound/alsa-utils package:

user $aplay -L
...
sysdefault:CARD=PCH
    HDA Intel PCH, ALC3246 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC3246 Analog
    Front output / input
...

This information can be used in an ALSA configuration file like this:

FILE ~/.asoundrc
defaults.pcm.!card PCH
defaults.pcm.!device 0
defaults.ctl.!card PCH

If the correct name is unclear, a list of valid names can be obtained from sysfs:

user $cat /sys/class/sound/card*/id
Q1U
HDMI
PCH
C930e

This shows the Q1U microphone is Q1U, the builtin HDMI is HDMI, the analog audio jacks are PCH, and a webcam's builtin microphone is C930e. Any of these are valid names for the card.

PulseAudio emulation

Some software (e.g. Firefox) makes use of the Pulse API. For PulseAudio support on a pure-ALSA system (i.e. one not using a sound server such as PipeWire or Pulse), install apulse.

S/PDIF or HDMI

With a default ALSA installation, an S/PDIF or HDMI connection might work "out of the box", without requiring any manual configuration of ALSA. If this is not the case, use aplay -L to find the appropriate card name and device number, as described in the the "Files" section above, then use that information in the following snippet for the appropriate ALSA configuration file:

FILE /etc/asound.conf
pcm.!spdif {
    type hw
    card PCH
    device 1
}
pcm.!default {
    type plug
    slave {
        pcm "spdif"
    }
}
Note
When playing sound files using aplay, the beginning of the playback will be clipped because the digital S/PDIF or HDMI connection is not held open and needs to be started each time a sound file is played.

The above configuration will not allow sound to be played from more than one sound application, or two sounds to be played simultaneously through the same sound card. In order to allow this, use the following configuration snippet for mixing (noting that doing so might result in interrupted output and/or a slight degradation in sound quality):

FILE /etc/asound.conf
# Share a single card with multiple applications 
pcm.!default {
    type plug
    slave.pcm "dmix:CARD=PCH,DEVICE=1,RATE=48000"
}

Cloning audio for two or more devices

Sometimes there's a need to clone audio: for example, using two cloned screens with different inputs, where the first screen is HDMI, and the second screen is DVI and analog audio.

The following snippet provides such a configuration. Adjust it as necessary for the system to which it's being applied.

Refer to this forum discussion for more information.

FILE /etc/asound.conf
ctl.!default {
    type hw
    # Set default card
    card PCH
}
 
pcm.!default both
 
pcm.both {
    type softvol
    slave {
        pcm {
            type plug
            slave {
                pcm {
                    type route
                    slave {
                        pcm {
                        type multi
                        slaves.a.pcm {
                            type dmix
                            ipc_key 2589455
                            ipc_perm 0666
                            slave {
                                pcm {
                                    # Add the default card - change to suit sound card #1
                                    type hw
                                    card PCH
                                    device 0
                                }
                                buffer_size 4096
                                channels 2
                            }
                        }
                        slaves.b.pcm {
                            type dmix
                            ipc_key 4855689
                            ipc_perm 0666
                            slave {
                                pcm {
                                    # Add the slave card - change to suit sound card #2
                                    type hw
                                    card PCH
                                    device 7
                                }
                                buffer_size 4096
                                channels 2
                            }
                        }
                        slaves.a.channels 2
                        slaves.b.channels 2
                        bindings.0.slave a
                        bindings.0.channel 0
                        bindings.1.slave a
                        bindings.1.channel 1
                        bindings.2.slave b
                        bindings.2.channel 0
                        bindings.3.slave b
                        bindings.3.channel 1
                    }
                }
                ttable.0.0 1
                ttable.1.1 1
                ttable.0.2 1
                ttable.1.3 1
            }
        }
    }
}
control {
    # Define volume control name
    name PCM
    # Set to the default card
    card PCH
}

A/52 / Dolby AC-3 / Dolby Digital and DTS

Sound cards providing S/PDIF output can do lossy compressed multichannel audio passthrough. An S/PDIF or HDMI connection is required for passthrough of advanced encoding; analog connections (RCA and minijacks) don't support any advanced encoding.

If a sound card states it has S/PDIF, it will also likely pass A/52 (also known as Dolby AC-3 and Dolby Digital) and/or DTS, even if neither is specifically listed as a feature. When a card lists one or both, it's because the vendor provides software for upmixing, or provides the decoded signal through analog output.

Note
Decoding from, or encoding to, A/52 or DTS requires a license; having a sound card with multichannel support often provides such a license. Refer to this article for more information.

For A/52 support, install the media-plugins/alsa-plugins package with the ffmpeg USE Flag enabled.

Audio/multimedia players might need multichannel codecs specified in their configuration, to allow the provision of hardware passthrough rather than downmixing.

Encoding to A/52

To simulate A/52-encoded audio from standard one- or two-channel audio streams or files:

FILE ~/.asoundrc
pcm.!default {
    type plug:surroundaudio
}
 
ctl.!default {
    type plug:surroundaudio
}
 
pcm.a52encode {
    type a52
    format S16_LE
    channels 6
    rate 48000
    bitrate 448
}
 
pcm.surroundaudio a52encode
 
ctl.surroundaudio {
    type hw
    card PCH
    device 1
}

Test the configuration with speaker-test(1):

user $speaker-test -Dsurroundaudio -c 6

The preceding snippet might not work with PCM 5.1 streams. Additionally, such streams might also require downmixing from S24_LE to S16_LE format: 24-bit is a common format for most media, but receivers can sometimes only decode 16- or 32-bit audio.

The following configuration snippet will encode a PCM 5.1 24-bit stream into a 16-bit A/52 stream, for streaming over S/PDIF. Note that this is not required when using HDMI, as HDMI can handle the bandwidth of a PCM 5.1 audio stream.

FILE ~/.asoundrc
# Make it possible to use A/52 with PulseAudio out of 
# the box. May also be useful for other use-cases.
 
pcm.a52 {
    @args [ CARD ]
    @args.CARD {
        type string
        default 0
    }
    type plug
    slave {
        pcm {
            type a52
            card $CARD
            bitrate 640 # Default 448
        }
        # Convert to S16 bit format, per S/PDIF spec
        format S16_LE
    }
}

Test the configuration with aplay(1):

user $aplay -D pcm.a52 /home/me/Music/Led_Zeppelin/Celegration_Day/PCM51-24bit/*.wav

JACK Audio Connection Kit

It is possible to interconnect JACK and ALSA. For more information, refer to this section of the "JACK" page.

Permissions

If the acl USE flag is enabled globally, and a login daemon (e.g. systemd-logind(8) or elogind) is being used, such as on systems using a desktop profile, sound card permissions will be handled automatically. Permissions can be checked using getfacl(1):

user $getfacl /dev/snd/controlC0 | grep larry
user:larry:rw-

A broader solution is to add the user accessing the sound card to the audio group.

root #gpasswd -a larry audio
Warning
Unless use of the dmix plugin has been configured, a user being in the audio group might result in a single application taking control of the sound card in a way that prevents other applications from using it. Note also that adding a user to the audio group is not needed when using PipeWire.

To confirm that the user has been added to the audio group, check the contents of /etc/group:

user $grep audio /etc/group
audio::18:larry

To apply this change generally, log out and back in again. To immediately apply this change within a current shell session, use newgrp(1):

user $newgrp audio

Service

OpenRC

The alsasound service saves and restores mixer levels. To start it manually:

root #rc-service alsasound start

To have the service start at boot, add it the boot runlevel using rc-update:

root #rc-update add alsasound boot

systemd

On systemd systems, ALSA state is preserved and restored automatically across system restarts.

The current ALSA state can be checked using the systemctl command:

root #systemctl status alsa-restore

Usage

This section assumes that the media-sound/alsa-utils package has been installed, as recommended in the "Software" section.

Test speakers

Use speaker-test(1) to test speakers:

user $speaker-test -t wav

Press Ctrl+C to interrupt the test.

Various options are available to specify the test output, e.g. the number of channels and the test type; refer to the man page for details.

For systems using 5.1 surround sound:

user $speaker-test -t wav -c 6 -D surround51

If speaker-test returns an error about IPC semaphore not being implemented, ensure the kernel's "System V IPC" option is enabled, as described in the "Kernel" section.

HDMI/SPDIF 5.1 and 7.1 speaker testing

The speaker-test(1) utility doesn't test audio with more than two channels over HDMI or SPDIF, but MPlayer and VLC can be used instead.

To do so, download a 5.1 channel (FLAC) or 7.1 channel (FLAC) speaker test file.

Then, play the provided sound file, specifying the HDMI or SPDIF device, the PCM file, and the number of channels (which will likely be either 6, for 5.1 surround, or 8, for 7.1 channel surround).

To test a 5.1 channel file using mplayer(1):

user $mplayer -channels 6 "/path/to/downloaded/flac_file.flac" -channels 6

To test a 7.1 channel file:

user $mplayer -channels 8 "/path/to/downloaded/flac_file.flac" -channels 8
Note
When testing in the absence of a default device, pass the additional option -ao alsa:device=hw=<value> where <value> is the value of the appropriate device.

To test a FLAC file using cvlc(1):

user $cvlc /path/to/downloaded/flac_file.flac

Test microphone

arecord(1) can be used to test a microphone.

The following will record until CTRL+C is pressed, and by default will provide a mono recording as a WAV file in U8 format:

user $arecord /tmp/test.wav

Use aplay(1) to play the saved file.

The file type, number of channels, and file format can be specified via the -t/--file-type, -c/{CmdOpt|--channels}}, and -f/--format options, respectively.

If a default audio device is not set, specify a device using arecord's --device option. using the -l/--list-devices option to find the relevant card and device number:

user $arecord -l
$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3246 Analog [ALC3246 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
user $arecord --device=hw:0,0 /tmp/test.wav
Note
The line or microphone channel might need to be unmuted. This can be done via alsamixer(1) or amixer(1).

Troubleshooting

For in-depth information about a program's usage of ALSA, such as its PID (owner_pid) and sample rate (rate), use the /proc interface. This can be done by substituting the relevant card/device details into the following command. Note that the /proc interface only lists physical devices, not virtual devices[1].

user $cat /proc/asound/card2/pcm0p/sub0/*
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 5513
buffer_size: 22050
card: 2
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 0
state: RUNNING
owner_pid   : 934
trigger_time: 86393.193574796
tstamp      : 86540.250594985
delay       : 17714
avail       : 4602
avail_max   : 7379
-----
hw_ptr      : 6485052
appl_ptr    : 6502500
tstamp_mode: NONE
period_step: 1
avail_min: 5513
start_threshold: 2147483647
stop_threshold: 22050
silence_threshold: 0
silence_size: 0
boundary: 6206523236469964800

No sound

If there's no sound, output channels may be muted. Unmute the channels, either by using the GUI environment's mixer, or by using alsamixer (from the media-audio/alsa-utils package), selecting the appropriate channels and pressing the M key to mute or unmute:

user $alsamixer

Custom ALSA config results in no sound in browsers

Try explicitly specifying defaults in the configuration:

FILE ~/.asoundrc
defaults.pcm.card <number of default sound card>
defaults.ctl.card <default sound card>

Note that, since Firefox 52 (released in 2017), support for direct output to ALSA has been dropped, and PulseAudio has been made a hard requirement. To address this, enable Firefox's pulseaudio flag and install apulse, which provides Pulse emulation for ALSA

Sound card only available for one application

Sometimes one app essentially takes over all sound devices, e.g. for performance reasons.

To force the use of dmix instead of direct audio output (which is what most things, such as Wine, use by default), when the device is card 1 device 7:

FILE ~/.asoundrc
pcm.dmixed {
    type asym
    playback.pcm {
        type dmix
        ipc_key 5678293
        ipc_perm 0660
        ipc_gid audio
 
        slave {
            channels 2
            pcm {
                format S16_LE # S32_LE
                rate 48000 # Can also be 44100
                type hw
                card 1 # Specify card number as appropriate
                device 7 # Specify device number as appropriate
                subdevice 0
            }
 
            period_size 1024
            buffer_size 8192
        }
 
        bindings {
            0 0
            1 1
# Uncomment below if using 6 channel
#           2 2
#           3 3
#           4 4
#           5 5
        }
    }
    capture.pcm "hw:0"
}
 
pcm.!default {
    type plug
    slave.pcm "dmixed"
}

Use of ~/.asoundrc is immediate: as long as use of a specific device is not being forced by any applications, applications will either begin to produce audio output immediately, or will require a restart. One of the best tests is to open a browser, go to YouTube, open a terminal, and use an audio or video player to try to play an audio or video file: success is indicated by an absence of errors (e.g. "Device or resource busy").

Missing dialogue/sound with 4.0 speakers

If using a 4.0 sound card (like an old SB Live), or 4.0 speakers in general, the dialogue in some games or movies might be very quiet or even missing. This is because most applications and movies support only either 2.0 (stereo) or 5.1 output. In order to achieve surround sound, the 5.1 audio track is used, but two channels are discarded: the center channel (which usually carries dialogue), and the subwoofer channel.

This issue can be circumvented by creating a virtual device which downmixes 5.1 to 4.0, mixing the center and subwoofer channels with other audio channels.

FILE ~/.asoundrc
pcm.downmix {
    type route
 
    slave {
        # The sound card output to be used
        pcm surround40
        # Real number of output channels
        channels 4
    }
 
# ttable.A.B G
# where A - input channel
#       B - output channel
#       G - volume gain (1.0 = original)
 
# Copy channels 0-3
    ttable.0.0 1
    ttable.1.1 1
    ttable.2.2 1
    ttable.3.3 1
 
# Mix channel 4 (center) into front speakers, and a bit (0.3) into rear ones
    ttable.4.0 1.0
    ttable.4.1 1.0
    ttable.4.2 0.3
    ttable.4.3 0.3
 
# Mix channel 5 (subwoofer) mostly (0.6) into rear speakers, and a bit (0.3) into front ones
    ttable.5.0 0.3
    ttable.5.1 0.3
    ttable.5.2 0.6
    ttable.5.3 0.6
}
 
ctl.downmix {
    type hw
    card 0
}

HDMI output from aplay has incorrect speaker channels

If MPlayer or VLC correctly plays a file in a 5.1 or 7.1 configuration over HDMI, but aplay doesn't, this might be caused by the snd_hda_intel HDMI audio module/driver, which is used by vendors other than Intel (e.g. Nvidia). Additionally, aplay might refuse to play the file if its format is 24-bit PCM 2.0/5.1 WAV.

To address these issues with minimal alterations to the PCM streams, remap the speaker channels. The following configuration is for both 5.1 and 7.1 audio. (If audio from a 7.1 stream should not be omitted, further map/copy the two extra channels to the 5.1 channels.) Additionally, as most HDMI-to Stereo-receiver connections only stream 16- and 32- bit formats, skipping 24-bit, the configuration up-mixes any PCM stream using the pcm.myHDMI profile to 32 bits.

FILE /etc/asound.conf
pcm.myHDMI {
    type plug
    slave {
        pcm "hw:1,7"
        format S32_LE
        channels 6
    }
    ttable {
        0.0= 1
        1.1= 1
        2.4= 1
        3.5= 1
        4.2= 1
        5.3= 1
        6.6= 1
        7.7= 1
    }
}

Weak center channel on PCM 5.1 live music

If a multi-channel soundtrack or piece of music has an apparently weak center channel, and the sound track is a live recording, it might be possible to map the center channel to the rear channels, e.g. when using mplayer:

user $mplayer -ao alsa:device=hw=1.7 Music/MyAlbum/PCM51-24bit/01.MyMusic.wav -channels 6 -format s32le -af channels=6:6:0:0:1:1:4:2:4:3:4:4:5:5

The above incantation of mplayer specifies:

  • an HDMI device of hw:1.7;
  • the PCM 5.1 audio file;
  • the number of channels;
  • the format (not needed if the receiver can natively handle 24 bit; receivers that can only natively handle 16- or 32-bit audio need to be upmixed); and
  • the mapping.

The mapping specifies:

  • a 6 channel audio stream, with 6 mappings immediately following, then to copy:
  • the left front channel to left speaker;
  • the right channel to right speaker;
  • the center channel to left rear speaker;
  • the center channel to right rear speaker;
  • the center channel to center speaker; and
  • the subwoofer channel to the subwoofer speaker.

Note that the rear channels on live recordings usually contain only the audience screaming, with very little music.

For further details, refer to the mplayer(1) man page.

Laptops with HDMI audio output

Some laptops with HDMI audio output will map HDMI as /proc/asound/card0, making it the default output device for applications. To change the device order, refer to the "Kernel modules" section.

Headset jack not working

Sometimes, to get a headset jack working, additional model information needs to be passed to the audio driver. For example, in case of a Dell Latitude E7470 laptop with snd-hda-intel driver, the following needs to be added to /etc/modprobe.d/alsa.conf:

FILE /etc/modprobe.d/alsa.conf
options snd-hda-intel model=headset-mic

More information can be found in this section of the Linux kernel documentation.

udev/alsactl errors on boot

Due to partitioning, encryption, or having a split /usr system, these errors may appear on boot:

root #journalctl -b | grep alsa
 
(udev-worker)[2594]: controlC2: Process '/usr/sbin/alsactl restore 2' failed with exit code 2.
 
(udev-worker)[2611]: controlC0: Process '/usr/sbin/alsactl restore 0' failed with exit code 2.
 
(udev-worker)[2579]: controlC1: Process '/usr/sbin/alsactl restore 1' failed with exit code 2.

To fix the issue, add TEST=="@sbindir@/alsactl" to /lib/udev/rules.d/90-alsa-restore.rules:

FILE /lib/udev/rules.d/90-alsa-restore.rules
TEST!="/etc/alsa/state-daemon.conf", TEST=="@sbindir@/alsactl", RUN+="/usr/sbin/alsactl restore $attr{device/number}"
TEST=="/etc/alsa/state-daemon.conf", TEST=="@sbindir@/alsactl", RUN+="/usr/sbin/alsactl nrestore $attr{device/number}"

For further details and discussion, refer to this discussion on alsa-devel and this discussion on bugs.debian.org.

No sound after rebooting following a system update

If, after a system update followed by a reboot, sound is not working, resulting in e.g. speaker-test(1) producing an error like:

 ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.14/work/alsa-lib-1.2.14/src/pcm/pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
 Playback open error: -2,No such file or directory

and alsaplayer(1) producing an error like:

 /usr/lib64/alsaplayer/output/libalsa_out.so failed to load
 NOTE: THIS IS THE NULL PLUGIN.      YOU WILL NOT HEAR SOUND!!

It might be that a stale /var/lib/alsa/asound.state file is present (e.g. due to the format of that file changing between kernel versions). Remove that file and reboot.

See also

  • Power management/Soundcard — describes the setup of power management of sound devices.
  • PipeWire — low-latency, graph-based, processing engine and server, for interfacing with audio and video devices.
  • PulseAudio — a multi-platform, open source, sound server that provides a number of features on top of the low-level audio interface ALSA
  • JACK — describes the setup of a playing sound with JACK (JACK Audio Connection Kit).

External resources

References