个人工具

UbuntuHelp:DebuggingSoundProblems/zh

来自Ubuntu中文

跳转至: 导航, 搜索

General Debugging

  • Check the volume in alsamixer: that sound is unmuted and that the volume is turned up
    • Unmute everything. Sometimes a muted channel will be the problem, even if the description doesn't seem immediately relevant.
    • Locating the volume controls:
      • Ubuntu: these controls are not the "sound" in preferences. Right click on panel; add to panel; volume controls; speaker icon appears on panel; left click on icon; preferences
      • Ubuntu 7.04: sound volume is also accessible from Menu->Sound&Video->Volume Control
      • Kubuntu: Alt-F2: kmix <enter>.
  • Check that your switches are set correctly (for instance that if you use the analog output the analog switch is set ON or that the digital or S/PDIF switch is set OFF).
      • You can select which tracks/switches are visible in Volume Control (see above) under Edit->Preferences.
  • Most sound applications output to card0 by default. In some cases, other audio devices (like a USB MIDI Keyboard) might be recognized as a soundcard and take card0, bumping your real soundcard to card1. `cat /proc/asound/cards` to see which devices are connected to which cards.
  • Test different "Sound Servers": Go to System > Preferences > Multimedia Systems Selector. From there, you can test the different options. For me, there are four different sound servers installed, and only one works. This is probably your problem if you cannot play audio with xine or rhythmbox, but you can with xmms or helix/realplayer.
  • Make sure that all users needing access to the Sound Device are members of the audio group (System->Administration->Users and Groups)
  • If you application sounds works, but your system sounds does not (login, logout, error sounds...) try removing the .asoundrc* files from your own directory (e.g. with 'rm .asoundrc*'). It should make the system sounds work without a reboot.
  • If you can get absolutely no sound and you have an onboard sound chip you can try to disable it in the BIOS. This solves the problem is some cases.

Reporting Sound Bugs

Please do not report problems on this page; use the normal support channels instead. See http://www.ubuntu.com/support

If you feel you have encountered a software bug, please report the bug at https://launchpad.net/ubuntu/+filebug

Manual Sound Information Collection

For automatic sound information collection see next section. All audio bug reports should have the output of these commands attached to the report. Please attach the output of each in a *separate* text file to the report. Modularity pleases everyone. https://launchpad.net/bugs/80907 is a good example :)


1) tail -2 /proc/asound/oss/sndstat

The above command lists the codecs involved. The output from this command is vital. Different codecs pushing the same driver (say, intel8x0, emu10k1, or hda-intel) exhibit a huge variation in errata.

2) amixer

It is imperative that you include the amixer output from your preferred (the one that's giving problems) audio device. The community has spent years documenting known mixer issues on http://alsa.opensrc.org/ (see drivers). For instance, many of the codecs driving cs46xx, emu10k1, and intel8x0 require multiple elements to be selected, unmuted, and raised to audible levels.

3) lspci -nv

The actual {sub,}{vendor,device} IDs are important. That's how we track whether something exists as a quirk or needs to be added/modified.

4) asoundconf list

This script command (which is really just filtered cat /proc/asound/cards) lists the enumerated sound devices on your system.

5) cat /etc/asound.conf ~/.asoundrc*

We need to know if you've modified any runtime configuration files that affect how alsa-lib interacts with your sound devices. The nonexistence of the above files is not a problem.

6) dmesg

Many codecs and drivers, upon initialization, will spit something via printk() into the kernel ring buffer. Any diagnostic messages will appear in this output.

7) cat /proc/interrupts

Sound devices require resources. We need to see if those resources are properly assigned.

Automatic Sound Information Collection

The following script gathers all required information in one go and uploads it to pastebin where it can be shared with the person assisting you. This script was written to aid the alsa developers, and also to help the people in #alsa to sort out sound issues. Further information and download is available from the linux-sound info site.

Manually installing sound drivers

You can use aplay to get a list of soundcards configured by alsa

$ aplay --list-devices
aplay: device_list:200: no soundcards found...

The following commands can help to figure out what sound card (chip set) you have (Look for lines that contain 'Multimedia audio controller')

$ lspci -v 
$ lspnp -v

Another useful script to gather specs about sound-cards and drivers is aadebug.

“A word about compatibility: even though most sound cards are claimed to be SoundBlaster compatible, very few currently sold cards are compatible enough to work with the Linux SoundBlaster driver. “ - http://www.tldp.org/HOWTO/Sound-HOWTO/x96.html#AEN120

Now figure out which module you need:

To see if this module is available on your system (it usually is) try the following command:

$ modinfo [modulename]

This will also list the possible parameters for the module. For example some ISA cards require you to pass isapnp=0 to modprobe. It may also require the IRQ and IO of the card if that's the case, these can be found in the output of the aadebug script.

Now that you've figured out all this information, lets try loading the module

#modprobe example
$ sudo modprobe snd_es18xx isapnp=0 port=0x220 mpu_port=0x330 dma1=1 dma2=5 irq=5 fm_port=0x388

If this doesn't return any errors, we can save the parameters.

$ echo options [module-name] [module-options] | sudo tee /etc/modprobe.d/[module-name]

Now we can test our setup

#aplay should now list your sound card
root@ubuntu:/etc # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ES1878 [ESS AudioDrive ES1878], device 0: ES1878 [ESS AudioDrive ES1878]
Subdevices: 1/1
Subdevice #0: subdevice #0
#the speaker should beep
$ /usr/bin/speaker-test  

PulseAudio

Suggested by DanielTChen

The recommended method is to use the pulseaudio daemon (esd replacement) and to leave/set applications to use ESounD output. See the Sound section in /usr/share/doc/mozilla-firefox/README.Debian


Software Mixing

A much better way of getting esd to work with non-esd-aware apps is to make alsa use its software mixer.

$ sudo /etc/init.d/alsa-utils stop $ gksudo gedit /var/lib/alsa/asound.state (add the following text verbatim to the start of this file) $ sudo /etc/init.d/alsa-utils start

# This text should be added to the beginning of
# /var/lib/alsa/asound.state.  You only need to add
# it once -- it is saved across reboots.

pcm.asymed {
type asym
playback.pcm dmix
capture.pcm dsnoop
}
pcm.default {
type plug
slave.pcm asymed
}
pcm.dmix {
type dmix
ipc_key 5678293
ipc_key_add_uid yes
slave {
pcm 'hw:0,0'
period_time 0
period_size 128
buffer_size 2048
format S16_LE
rate 48000
}
}
pcm.dsnoop {
type dsnoop
ipc_key 5778293
ipc_key_add_uid yes
slave {
pcm 'hw:0,0'
period_time 0
period_size 128
buffer_size 2048
format S16_LE
rate 48000
}
}

Now as many programs as you want can all use the sound card simultaneously, both the output and the microphone! ESD-aware apps can use ESD, other apps will still work fine.

One notable misfeature of ESD is that it often ruins the A/V sync when playing videos. After setting up the software mixer, you might find it useful to turn esd off altogether (in tthe Sound control panel uncheck "Enable Software Mixing"). Now, especially with GStreamer 0.10, your movies should have perfect A/V sync.

It's a shame that software mixing isn't enabled on Ubuntu by default.

More on Software Mixing

A problem is the default config is OSS doesn't let 2 apps make sound at the same time. Here is a report of how it was dealt with: Basically get esd to relinquish control of the sound when its not in use. Then add mixing for oss so you can use multiple oss programs at once, like Quake3 and Teamspeak, or in my case, Wolfenstein and Teamspeak

First use section 3 here: http://www.ubuntulinux.org/wiki/RestrictedFormats, then do this: http://alsa.opensrc.org/index.php?page=DmixPlugin


Handy links:

http://alsa.opensrc.org/index.php?page=OssEmulation http://doc.gwos.org/index.php/Comprehensive_Sound_Problems_Solutions_Guide