Subject: No Sound After Update To Jessie
From: Alex Kemp
Date: Sunday, 27 December 2015 00:00:00 +0000
To: All

Background:

I chose the beginning of the holiday season to update my home computer to Debian Jessie from Wheezy. It caused the normal amount of pain. There were 2 main problems after startup:

  1. No sound (was fine in Wheezy).
  2. No autostart Conky (appeared fine after manual startup; this issue also occurred with previous Wheezy setup, using the SLiM LM).

Resolution:

This is purely a setup issue.

In brief:

The wrong sound Card is being placed at index-0 at startup.

In exquisite detail:

Current desktop setup:

You will need alsa installed, and explicitly alsa-utils:

ALSA: Advanced Linux Sound Architecture alsa-utils: Description: Utilities for configuring and using ALSA    Included tools: * alsactl: advanced controls for ALSA sound drivers * alsaloop: create loopbacks between PCM capture and playback devices * alsamixer: curses mixer * alsaucm: alsa use case manager * amixer: command line mixer * amidi: read from and write to ALSA RawMIDI ports * aplay, arecord: command line playback and recording * aplaymidi, arecordmidi: command line MIDI playback and recording * aconnect, aseqnet, aseqdump: command line MIDI sequencer control * iecset: set or dump IEC958 status bits * speaker-test: speaker test tone generator

The above are command-line utilities. That’s how we can find the source of the problem, and also how to fix it.

Let’s start at the easy end:-/p>

alsamixer:

The most usual reason for no-sound is that the Master volume control (or the volume control for the sub-device in use) is muted. Make sure that something should be playing sound. Then, at the terminal screen, issue the command: "alsamixer" (no quotes). You can see what my screen showed below just now (it is currently working fine).

alsamixer on a working system (press ‘m’ to toggle the mute)

If the control was muted it would show 2 x ‘M’ (rather than the 2 x ‘0’ that it shows now). If you press ‘m’, then it will toggle the slider between the muted (‘MM’) state & the not-muted (‘00’) state - the change to the control is instantaneous. Press ‘Esc’ (Escape key) to leave the screen.

The slider(s) shown is/are for the default card in the system. I now have the correct card registered at index-0 (and thus the default), though that was not the case immediately after the update. It is possible to switch alsamixer to use & show controls for a different soundcard device by index number/id or by name (use “man alsamixer”, or “info alsamixer”, or “alsamixer --help” to get more information). Our use just now is as a very fast check to make sure that the sliders for the default are not muted, so we are not going to take this any further if a ‘m’ does not immediately let you hear a CD/sound file/whatever it is that is playing.

aplay:

The command-line utility aplay will not only allow us to playback sound-files; it will also allow us to list all the soundcards on the system by index & also by name. We will need that information later.

At the terminal screen, issue the command: "aplay-l" (no quotes). This is what I got just now:- $ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Intel [HDA Intel], device 0: STAC9227 Analog [STAC9227 Analog]   Subdevices: 1/1   Subdevice #0: subdevice #0 card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]   Subdevices: 8/8   Subdevice #0: subdevice #0   Subdevice #1: subdevice #1   Subdevice #2: subdevice #2   Subdevice #3: subdevice #3   Subdevice #4: subdevice #4   Subdevice #5: subdevice #5   Subdevice #6: subdevice #6   Subdevice #7: subdevice #7 card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]   Subdevices: 8/8   Subdevice #0: subdevice #0   Subdevice #1: subdevice #1   Subdevice #2: subdevice #2   Subdevice #3: subdevice #3   Subdevice #4: subdevice #4   Subdevice #5: subdevice #5   Subdevice #6: subdevice #6   Subdevice #7: subdevice #7

Once again, recall that my system is currently working fine, so the “HDA Intel” device is showing as “card 0” (which means that it is the default). Immediately after update to Jessie this command was showing the Loopback device as ‘card-0’ & the Intel device as ‘card-1’. I suspected at the time that it might be the wrong way round.

Although the above is useful, we actually need some more-detailed information, which may well swamp us!

Issue now the command: "aplay -L | grep :CARD" (no quotes) (output device names). This is what I got:- $ aplay -L | grep :CARD sysdefault:CARD=Intel front:CARD=Intel,DEV=0 surround21:CARD=Intel,DEV=0 surround40:CARD=Intel,DEV=0 surround41:CARD=Intel,DEV=0 surround50:CARD=Intel,DEV=0 surround51:CARD=Intel,DEV=0 surround71:CARD=Intel,DEV=0 dmix:CARD=Intel,DEV=0 dsnoop:CARD=Intel,DEV=0 hw:CARD=Intel,DEV=0 plughw:CARD=Intel,DEV=0 sysdefault:CARD=Loopback front:CARD=Loopback,DEV=0 surround21:CARD=Loopback,DEV=0 surround40:CARD=Loopback,DEV=0 surround41:CARD=Loopback,DEV=0 surround50:CARD=Loopback,DEV=0 surround51:CARD=Loopback,DEV=0 surround71:CARD=Loopback,DEV=0 dmix:CARD=Loopback,DEV=0 dmix:CARD=Loopback,DEV=1 dsnoop:CARD=Loopback,DEV=0 dsnoop:CARD=Loopback,DEV=1 hw:CARD=Loopback,DEV=0 hw:CARD=Loopback,DEV=1 plughw:CARD=Loopback,DEV=0 plughw:CARD=Loopback,DEV=1

The computer is an ancient Dell Dimension E520. It only has a single embedded sound chip within the motherboard (hence the “HDA Intel” device), but it has multiple sound output & microphone (input) devices at both front & back of the computer. That is a large number of devices, each of which gets split into 2 (hardware + loopback). There is thus a vast amount of information that gets output by this command; hence the grep, as all we need is the card name (less the ‘DEV’ name, unless you need to specify 1 of 2 devices that have the same name).

I correctly guessed at the time that ‘sysdefault’ were the important device names, and tried both “sysdefault:Loopback” and “sysdefault:Intel”. Only the second (or “sysdefault:CARD=Intel”) worked.

Having confirmed that the default device is NOT muted, we now need to find if one of the other devices will play sound. To do that, we use those device names in conjunction with the very useful “speaker-test -c 2” command (c = 2 speakers for me) (--help will also work with this command). At the time nothing happened, although now it works fine (notice that I cut it off early using Ctrl-C) (and the speaker designations are actually correct!):- $ speaker-test -c 2 speaker-test 1.0.28 Playback device is default Stream parameters are 48000Hz, S16_LE, 2 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 96 to 1048576 Period size range from 32 to 349526 Using max buffer size 1048576 Periods = 4 was set period_size = 262144 was set buffer_size = 1048576 0 - Front Left 1 - Front Right Time per period = 10.971955 0 - Front Left 1 - Front Right Time per period = 10.971753 0 - Front Left ^C 1 - Front Right Time per period = 5.489586

If you are having problems then--like me--the output above will probably appear on the screen, but the speakers will be silent. Imagine, then, how happy I was when my very next command worked!

The command as shown above attempts to play the sound through the default device. To play through any other device you need to make use of the -D (device) option. This is the command which worked both at the time & also just now: $ speaker-test -Dsysdefault:Intel -c 2 speaker-test 1.0.28 Playback device is sysdefault:Intel Stream parameters are 48000Hz, S16_LE, 2 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 2048 to 8192 Period size range from 1024 to 1024 Using max buffer size 8192 Periods = 4 was set period_size = 1024 was set buffer_size = 8192 0 - Front Left 1 - Front Right Time per period = 5.821873  0 - Front Left  1 - Front Right Time per period = 5.973250  0 - Front Left  1 - Front Right (cut off with Ctrl-C)

At this point, I knew for sure that the 2 devices had been setup the wrong way round. What was necessary was to make sure that the correct device (the “HDA Intel”) would be setup as “card-0” & thus become the default at startup. We need to create/edit an ALSA cofig file to do that:

alsa-base.conf:

asoundrc:

There are 2 places that ALSA uses as a config file. As is so often the case, these are either for global (‘alsa-base.conf’) or local config (‘asoundrc’): global config file: (# chmod 644) /etc/modprobe.d/alsa-base.conf                                   /etc/asound.conf local config file:  ($ chmod 644) ~/.asoundrc

I could find neither file on my system. Therefore, I used sudo nano /etc/modprobe.d/alsa-base.conf to create the following file:- $ cat /etc/modprobe.d/alsa-base.conf # 2015-12-26 added # note: index=-2 tells ALSA never to use that card as primary (default) options snd_hda_intel index=0 options snd_aloop index=-2

There is a big question at this stage: how can we find the names of the device drivers? The answer is, like this: $ cat /proc/asound/modules  0 snd_hda_intel  1 snd_aloop

(all sound devices begin with ‘snd’)
(again, notice that now they are the correct way around)
(it is necessary to restart the computer for this to take effect)

It is possible to confirm the hardware name with “lspci -v” (no quotes) for PCI hardware (this is the extract from my system): $ lspci -v ... 00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02)    Subsystem: Dell Device 01dd    Flags: bus master, fast devsel, latency 0, IRQ 44    Memory at dfddc000 (64-bit, non-prefetchable) [size=16K]    Capabilities:    Kernel driver in use: snd_hda_intel

As a little extra, there are some standard .wav sound-files to play (ignore the names, as they will NOT play to the different speakers): aplay /usr/share/sounds/alsa/*.wav

links:

ALSA; Debian Wiki: https://wiki.debian.org/ALSA
ALSA; ArchLinux Wiki: https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture
(2nd answer was best): http://superuser.com/questions/626606/how-to-make-alsa-pick-a-preferred-sound-device-automatically

---------
Alex Kemp