How to fix Debian/Slax Linux playing no sound on laptops

I encountered this issue while trying to boot a Slax Linux (https://www.slax.org/) image on a laptop. I’ve read that this issue sometimes occurs on Debian as well, which is plausible since Slax is based off Debian now. I haven’t tested the fix on Debian yet, but it should work in theory since they’re related.

The issue in itself is the user not being able to play audio and encountering errors like these:

VLC fails to play audio
ALSA Basic Audio Test fails
speaker-test fails

 

 

 

 

 

 

 

 

 

There are multiple ways to fix this problem, some more simpler than the other. The crux of the matter is Linux detecting multiple audio devices and using one that’s not actually in use (example: using the missing HDMI audio output as default instead of the usuable analog). We fix it by changing the default audio card.

Method 1: setting the ALSA configuration file at /etc/asound.conf or ~/.asoundrc

ALSA stands for Advanced Linux Sound Architecture, the framework that connects the Linux kernel with sound card drivers. We need to configure ALSA so that it uses the correct sound card for audio playback.

The /etc/ directory is used to hold configuration files. Our ALSA config file needs to be named asound.conf. We need to find the id numbers of our connected sound cards and create the asound.conf configuration file to set our desired device as the default. From the ALSA project wiki [https://www.alsa-project.org/wiki/Setting_the_default_device and https://www.alsa-project.org/wiki/Asoundrc], we can see the ids of the connected sound cards with the command:

cat /proc/asound/cards

cat /proc/asound/cards

We can also list all sound cards with aplay -l

aplay -l

We can then use any text editor to make the asound.conf config file and put the following text in it:

pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}

OR

defaults.pcm.card 1
defaults.ctl.card 1
Editing asound.conf

I’m using the id 1 to set the Intel PCH analog sound card as the default instead of the HDMI card which clearly doesn’t work since it’s not connected to an HDMI output. Replace 1 with the id of whichever card you want to use. Save the file and exit. The audio should start working now.

Alternatively, instead of making /etc/asound.conf you can create .asoundrc in your home directory instead. This is useful if only want to make changes for your own user and not system-wide (which is what happens with asound.conf).

Method 2: Using PulseAudio

PulseAudio is a sound server that works with ALSA and routes audio streams. It comes pre-installed with most Linux distributions and desktop environments. However, Slax itself doesn’t come with PulseAudio. We’ll need an internet connection to download PulseAudio on Slax. Use apt to install it:

apt-get install pulseaudio

[use sudo apt-get install pulseaudio if you’re not root/superuser]

Start the PulseAudio server with the command:

pulseaudio --start

Now, use the pactl command to set the correct sound card as the audio source for PulseAudio. The PulseAudio server system uses sinks to get and play audio from sound sources

pactl list short sinks       #list all sinks
pactl list short sources     #list all sources
pactl set-default-sink 0     #set default sink, replace 0 with your desired sink id
pactl set-default-source 1   #set default source, replace 1 with your desired source id
Match the correct sound sink to sound source with pactl

You can also alternatively use pacmd for an interactive shell to configure PulseAudio. The commands are essentially the same.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s