Troubleshooters.Com, T.C Linux Library and T.C Linux Sound Station Present

Troubleshooting Linux Audio

Copyright (C) 2008 by Steve Litt, All rights reserved. Material provided as-is, use at your own risk. 



Steve Litt is the author of the Universal Troubleshooting Process Courseware,
which can be presented either by Steve or by your own trainers.

He is also the author of Troubleshooting Techniques of the Successful Technologist,
Rapid Learning: Secret Weapon of the Successful Technologist, and Samba Unleashed.


Contents

Disclaimer

You use this document at your own risk. I am not responsible for any damage or injury caused by your use of this document, or caused by errors and/or omissions in this document. If that's not acceptable to you, you may not use this document. By using this document you are accepting this disclaimer.

The Universal Troubleshooting Process

Here's the Universal Troubleshooting Process:
  1. Prepare
  2. Make a damage control plan
  3. Get the symptom description
  4. Reproduce the symptom
  5. Perform corrective maintentance
  6. Narrow it down
  7. Repair or replace the defective component
  8. Test
  9. Take Pride
  10. Prevent future occurrence

Prepare

Get your attitude right. Sound problems, especially on sound cards not installed by you, ESPECIALLY on laptops, can be a bear. Understand it might take awhile. Understand that setbacks don't reflect badly on your abilities, as long as you can quickly restore the system back to the way you found it.

Learn as much as possible about Linux audio. This includes theory, driver types, and predefined diagnostics.

Make a damage control plan

Back up. If you do things through the GUI, write down original configurations so you can restore if you screw it up. Make sure you can quickly restore the system back to the way you found it.

Get the symptom description

What indicates to you that there's a malfunction? Is there sound? Is the sound too soft? Does the sound work through the built in speakers but not through the speaker jack? When did it start malfunctioning? What can be done to reproduce the symptom? What can be done to get rid of the symptom? What other observations do you have?

Reproduce the symptom

Guided by the symptom description, try to reproduce the symptom, noting exactly what sequence of steps you took in order to reproduce it.

Perform corrective maintentance

Now try to play a song:
play mysong.ogg
and then
mplayer mysong.ogg
One of three things happens with these commands:
  1. It errors out with a message
  2. It appears to play but no sound comes out
  3. It plays and sound comes out
#3 means it's working. #2 is probably a muting/mixer problem, or your external speakers aren't plugged in or aren't working and you have no internal speakers. #1 is probably a sound driver problem.

If distortion's a problem, try raising the volume on the physical speaker, and lowering the mixer volume controls, or vice versa.

Here are some other quick and dirty information gatherers. Perform them quickly and record the information for analysis:
To find what kind of soundcard you have1
lspci -vv | grep -i -A10 audio
To find out what drivers your system is trying to load
grep "sound-" /etc/modprobe.conf
To find out if a sound driver is loaded1
/sbin/lsmod | grep drivername
To find mixer settings
aumix -q
To crank the play volume all the way, disabling any mute
aumix -v 100 -w 100
To run an interactive text mode mixer
aumix-text
or
taumix
or
alsamixer
or
amixer
To see whether a sound device exists (driver loaded, etc)
ls /dev/dsp
To learn about sound device conflicts (who's using it)
/sbin/fuser -v /dev/dsp
To find out what driver your sound card "is supposed to use"     Separate article
To restart your sound the ALSA way12
/etc/init.d/alsasound
Footnotes:
  1. Do this as root
  2. Might be called something else, like /etc/init/alsa

Narrow it down

If you get this far without finding the root cause, be creative in thinking up new diagnostic tests to narrow the root cause scope. Always remember the Troubleshooter's Philosophy: Don't try to fix it, just try to narrow it down! If you narrow it down several times, the root cause will become obvious.

If you get stuck, recite the Troubleshooter's Mantra: How can I narrow it down just one more time? Many times the answer is as simple as doing more research.

If you get an error message, try placing that error message in a search engine. It's almost certain others will have had the same problem. Unfortunately, most references to the error message will ask questions, while few will give authoritative advice, and almost none will bother placing <SOLVED> in the subject and telling the world what finally worked. Remember, when you fix the problem, be a good citizen and tell the rest of us how you solved it.\

Repair or replace the defective component

Be sure to back up so that if anything goes wrong, you won't have made things worse. Then add the driver, the code, the modprobe command(s), or whatever else you need to do to fix it.

Test

Answer these four questions:
  1. Did the symptom go away?
  2. Do I know why the symptom went away?
  3. Did I fix it the right way (fix root cause, not symptom)?
  4. Did any new problems appear?
Note that with intermittent problems, #1 must be checked over a period of time considerably longer than the longest time between toggles obeserved while reproducing the problem.

Once these four questions can be answered satisfactorily, the repair is complete, and things can be wrapped up.

Take Pride

Troubleshooting is mentally intense, so you need a break. Take a few minutes to celebrate your victory over the problem. Ask yourself where you were brilliant, and where you could do even better next time. If practical, take a walk while taking pride.

Prevent future occurrence

Whatever human factors caused this problem, try to make sure they don't happen again. Policies and documentation are excellent preventatives.

Why Dedicated?

Finding the Right Driver for the Sound Card

One of the worst feelings is a no-sound computer with an unknown sound interface. Once you've ruled out muting and nonfunctioning or unplugged external speakers, you know you're in for a battle.

Take heart though. Windows users have it much worse if they don't know the sound interface, because their OS doesn't come with drivers. Instead, they have to get drivers on a CD from the soundcard manufacturer, not knowing what the sound card is. Ugh!

Anyway, the first thing you do is preserve the info you do have. Back up your /etc/modprobe.conf file, and any sound related files in the /etc/modprobe.d directory, and if you have an /etc/modules.conf or /etc/conf.modules, that too. Next, use your Linux distribution's audio configuration utility to find out everything you can -- the name of your sound card, the name of the manufacturer, the driver it's currently using, and if there's such a utility, the driver it should use. As mentioned, this varies from distro to distro.

Next, try to reconfigure the sound card with the sound card config program. It might work, saving you considerable time. Remember after the reconfiguration to recheck the mixer volumes if it still doesn't play. Then it it still doesn't play, restart ALSA with the following command (varies with distro):
/etc/init.d/alsasound restart
Remember to recheck the mixer settings again before testing for play ability.

Finding the Driver from Scratch

If you got to this point and it's still not working, you'll probably need to find the driver from scratch -- an ugly proposition but not a showstopper if you follow the right procedures. It involves solving several subproblems:
  1. What kind of sound hardware do I have?
  2. What ALSA driver is that hardware supposed to use?
  3. Where do I find the driver?
  4. How do I install the driver?

What kind of sound hardware do I have?

This is actually pretty easy to answer with any reasonable Linux distribution. Logged in as root perform the following commands:

[root@mylap2 ~]$ lspci -v | grep -i audio
00:14.2 Audio device: ATI Technologies Inc SB450 HDA Audio (rev 01)
[root@mylap2 ~]#

The preceding gave you the vendor's name (ATI) and the device name (SB450 HDA Audio). More importantly, it gave you the bus location (00:14.2). Armed with that bus location you can find out the vendor number, device number, subvendor number and subdevice number, as shown in the next command:

[root@mylap2 ~]# lspci -vvvn | grep -A10 00:14.2
00:14.2 0403: 1002:437b (rev 01)
Subsystem: 1025:009f
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR-
Latency: 64, Cache Line Size: 32 bytes
Interrupt: pin ? routed to IRQ 17
Region 0: Memory at c0000000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [50] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [60] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable-
[root@mylap2 ~]#

On line 1 of the preceding command's output, you see that the vendor number is 1002, and the device number is 437b. On line 2 of the output, you find out that the subvendor number is 1025, and the subdevice number is 009f. These four numbers are probably the most precise and accurate way to identify a piece of PCI hardware, although too few references use them.

Now it's time to get names corresponding to those four numbers, because the names might be helpful in your search:




      

What ALSA driver is that hardware supposed to use?

Where do I find the driver?

How do I install the driver?


Another necessity is finding the correct driver for the hardware. This is distribution specific and difficult. In the case of Mandriva 2007 Linux you do it like this:
[slitt@mylap2 ~]$ lspcidrake -v | grep -i audio
snd-hda-intel : ATI Technologies Inc.|SB450 Azalia HD audio (vendor:1002 device:437b subv:1025 subd:009f)
[slitt@mylap2 ~]$

The preceding shows that the driver that "should be" used with the device is snd-hda-intel. You can look up the vendor, device, subvendor and subdevice numbers in /usr/share/pci.ids, or at http://pciids.sf.net/. If your distro doesn't have a nice lookup like that, you might need to do some fancy footwork to find the preferred driver. Sometimes the best bet is to boot a live CD with excellent hardware detection, such as the latest Knoppix, or maybe the latest live Ubuntu.

If that doesn't work, you can find the vendor number, device number, subvendor number and subdevice number with a process. First find the bus location of the audio card:

[root@mylap2 ~]$ lspci -v | grep -i audio
00:14.2 Audio device: ATI Technologies Inc SB450 HDA Audio (rev 01)
[root@mylap2 ~]#

The first field, printed large in the preceding, is the bus location. Armed with the bus location, you can find all the numbers like this:

[root@mylap2 ~]# lspci -vvvn | grep -A10 00:14.2
00:14.2 0403: 1002:437b (rev 01)
Subsystem: 1025:009f
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR-
Latency: 64, Cache Line Size: 32 bytes
Interrupt: pin ? routed to IRQ 17
Region 0: Memory at c0000000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [50] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [60] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable-
[root@mylap2 ~]#

In the preceding, the 1002:437b in the first line of output means vendor number 1002, and device number 437b. On the next line, the 1025:009f means subvendor 1025, subdevice 009f. Armed with those numbers, you can look up the corresponding names at either /usr/share/pci.ids, or at http://pciids.sf.net/.




Last but not least, you might be able to find the correct driver online, by using the lspci command, which is not distro specific:





I

Creating Your Grub Partition

U

Setting Up Your Grub Partition

T

Making Your menu.lst

I

king it Happen at Boot Time

Y

Adding a New Distro

T

The Case for Doing this On Every Hard Disk

A p

Back to Troubleshooters.Com * Back to Linux Library * Back to Grub Grotto