How To Fix ALSA "Host is down" Error
On a new laptop I built I started getting a strange error when running basic audio-related programs:
% amixer
amixer: Mixer attach default error: Host is down
% alsamixer
cannot open mixer: Host is down
% aplay test.wav
aplay: main:834: audio open error: Host is down
% arecord test.wav
arecord: main:834: audio open error: Host is down
% mpv test.wav
(+) Audio --aid=1 (pcm_s16le 2ch 44100Hz)
[ao/alsa] Playback open error: Host is down
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
[ao/jack] cannot open server
[ao/sdl] could not open audio: ALSA: Couldn't open audio device: Host is down
[ao] Failed to initialize audio driver 'sdl'
Could not open/initialize audio device -> no sound.
Audio: no audio
Exiting... (Errors when loading file)
This is on a brand new installation that barely has anything on it... which host is being down??
I had no ALSA configuration whatsoever on the machine (no /etc/asound.conf
,
no ~/.asoundrc
).
aplay -l
shows that there are devices available:
% aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC257 Analog [ALC257 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
Workaround
Before I figured out what the issue was, I figured out how to perform audio-related tasks working - specifying the device manually works:
amixer -c 0
amixer -D hw:0
alsamixer -c 0
aplay -D hw:0 test.wav
arecord -D hw:0 test.wav
mpv --audio-device=alsa/hw:0 test.wav
Interestingly enough, once alsamixer
opens with the card 0, using F6
we can see the list of devices, and selecting the (default)
device
produces the same error we are having elewhere:
Cannot open mixer device 'default'.
Host is down
Cause
Running aplay -L
reveals what has happened to our system:
% aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
pipewire
PipeWire Sound Server
default
Default ALSA Output (currently PipeWire Media Server)
hw:CARD=PCH,DEV=0
HDA Intel PCH, ALC257 Analog
Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct hardware device without any conversions
...
We see that the default ALSA output somehow got pointed to the "PipeWire Media Server".
ArchLinux's PipeWire wiki page
helpfully states that pipewire-alsa
package routes "all applications
using the ALSA API through PipeWire".
Sure enough, I have the pipewire-alsa
package installed.
Inspecting its files via dpkg -L pipewire-alsa
reveals
/usr/share/alsa/alsa.conf.d/99-pipewire-default.conf
with the
following contents:
pcm.!default {
type pipewire
playback_node "-1"
capture_node "-1"
hint {
show on
description "Default ALSA Output (currently PipeWire Media Server)"
}
}
ctl.!default {
type pipewire
}
The pipewire
device itself is defined in
/usr/share/alsa/alsa.conf.d/50-pipewire.conf
.
Both of these files are symlinked from /etc/alsa/conf.d
.
So much for me checking for /etc/asound.conf
- my system turns out to have
ALSA configuration in another place.
While the definition of the pipewire
device is possibly harmless,
routing of all audio through it is most certainly not.
How did I get this on my system? Attempting to remove pipewire-alsa
causes Apt to prompt to replace it with pulseaudio
. Hmm, no thank you.
Running apt-get remove pipewire-alsa pulseaudio
prompts me to remove
gnome-settings-daemon
, which I guess came in as one of the dependencies
of something I tried to use earlier to try to
get the bitmap fonts working.
Solutions
The sensible solution is to simply remove
/etc/alsa/conf.d/99-pipewire-default.conf
.
If only life was this simple.
Since this file was automatically added, will it possibly come back by itself?
Yes, it will, if pipewire-alsa
is reinstalled.
In fact, pipewire-alsa
is quite insistent on getting this file into
your system:
- If you replace this symlink with a plain file (say, an empty one),
installing
pipewire-alsa
will silently replace your plain file with the symlink back to/usr/share/alsa/alsa.conf.d/99-pipewire-default.conf
. -
If you make
/etc/alsa/conf.d/99-pipewire-default.conf
immutable withchattr +i /etc/alsa/conf.d/99-pipewire-default.conf
, installation ofpipewire-alsa
will fail altogether:apt install pipewire-alsa
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: pipewire The following NEW packages will be installed: pipewire pipewire-alsa 0 upgraded, 2 newly installed, 0 to remove and 18 not upgraded. Need to get 0 B/153 kB of archives. After this operation, 327 kB of additional disk space will be used. Do you want to continue? [Y/n] Selecting previously unselected package pipewire:amd64. (Reading database ... 86429 files and directories currently installed.) Preparing to unpack .../pipewire0.3.80-2amd64.deb ... Unpacking pipewire:amd64 (0.3.80-2) ... Preparing to unpack .../pipewire-alsa0.3.80-2amd64.deb ... Unpacking pipewire-alsa:amd64 (0.3.80-2) ... dpkg: error processing archive /var/cache/apt/archives/pipewire-alsa0.3.80-2amd64.deb (--unpack): unable to make backup link of './etc/alsa/conf.d/99-pipewire-default.conf' before installing new version: Operation not permitted Errors were encountered while processing: /var/cache/apt/archives/pipewire-alsa0.3.80-2amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
If you don't want to risk your system audio being broken all of a sudden, you need to apply your own default PCM configuration, such as the following:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
This configuration can go into either /etc/asound.conf
,
/etc/alsa/conf.d/99-zzz-default-pcm.conf
or ~/.asoundrc
.
Note that pipewire-alsa
sets up its routing of ALSA to PipeWire at
the highest priority (99) - way to go, whoever thought this up.
A more radical solution, of course, is to remove pipewire
altogether.
This on my system prompts me to install pulseaudio
instead with all
of its routing of ALSA to itself by default. Specifying the removal
of both pipewire
and pulseaudio
will, I expect, result in removal
of all programs that are part of "the Gnome desktop".
Of course, if you remove PipeWire from your system without adding an
explicit default PCM, PipeWire can come back as a dependency if you are
not carefully examining Apt's installation proposals, returning you
to this issue at a future time.