August 30, 2020 notes:
Warning this is a very old post from 2014.
The information presented here may no longer apply to modern systems.
Please contact your GNU/Linux distribution of choice community for help with PulseAudio.
You might be interested in [added 08/04/14 04:30 PM]:
This method has been tested in Linux Mint “petra” 16, it should work nicely
with other linux distributions.
Before you start:
This solution has worked for me. I’m still testing it, usually it’s easy
to run into any underrun problem after alt-tabbing from games several times.
I’m still testing this solution. I need more people to test it too so we can
be sure that we eliminated the problem.
What we are going to do today is fix this annoying issue. What are the
symptoms of having this problem?
- In console: You will receive a lot of warnings saying ALSA lib pcm.c:7843:(sndpcmrecover) underrun occurred
- The sound gets distorted, filled with static and it plays really fast.
- Due to PulseAudio failing to recover, it will keep retrying thus using even more CPU. (It ends up hogging the CPU)
This solution was originally based on WINE And PulseAudio
solution. Like it mentioned, using
such solution will remove a features PulseAudio provides to multiple
soundcards. I decided to look a bit further since I wanted to use the
following audio output sources: video card’s HDMI, USB Speakers, and headset.
This is the final result:
Be able to move Audio Output to other Playback Devices
Well, I’m sure you want to get started into applying the solution in your own
system. So let’s get started.
Like I said before, this has been tested in Linux Mint, this guide is using
examples that will appear in Linux Mint. You will have to adapt this
solution in whatever way your distribution has PA set up. I edit the files
/etc/pulse/default.pa, even if they are there it doesn’t start as a system-
wide daemon. However, there’s a high chance that your configuration is in
~/.config/pulse/default.pa. It’s your task to
find which configuration your PA uses in your distribution community forum.**
Or you can just use:
As you have noticed I use KDE, so I’ll be using Kate text editor to open
my configuration files.
- Do not type “$”, the dollar sign in the terminal. This is used to hint the reader that I’m writing a command in the terminal.
We are going to check how many soundcards your system detects. For this we
will do the following command
$ cat /proc/asound/cards
This will print the following (the results won’t be the same):
david@david-desktop:~ > cat /proc/asound/cards 0 [PCH ]: HDA-Intel - HDA Intel PCH HDA Intel PCH at 0xfb400000 irq 52 1 [NVidia ]: HDA-Intel - HDA NVidia HDA NVidia at 0xfb080000 irq 17 2 [MicroII ]: USB-Audio - Audio Advantage MicroII C-Media INC. Audio Advantage MicroII at usb-0000:06:00.0-1, full speed
Let’s take a look at this. We have 3 soundcards installed
* 0 is my Intel on-board audio card. * 1 is my NVIDIA GeForce GT400 HDMI output * 2 is my USB Audio Speakers
So what’s with the numbers? They are called deviceid in PulseAudio. This
tells PulseAudio “hey man, load this card with this unique deviceid for me,
will ya?”. So that’s what PulseAudio will do in t he following examples.
Now that we have the device id, let’s open /etc/pulse/default.pa. It’s
up to you to choose what you are going to load or not.
Back up your default.pa first
sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak
sudo kate /etc/pulse/default.pa
Search for module-udev-detect and module-detect,
disable them by adding a # at the start of the line. As presented in the
Here we are telling PulseAudio. “I’ll be the one deciding what to load or
not”. We are disabling the automatic detection.
Now comes the important part
Above those lines there are these ones, find module-alsa-sink and
uncomment it, like this
This is an example.
The first, and *most important line *we are going to add is
load-module module-alsa-sink device=dmix
(Optional) What is dmix?
PCM plugins extend the functionality of PCM devices allowing low-level sample
conversions and copying between channels, files and soundcard devices. The
dmix plugin provides for direct mixing of multiple streams.
What we are telling PulseAudio is “don’t hog the hardware directly, use dmix
as your default device”. PulseAudio will make the first available sink as
default. (This is an assumption I made)
If you remember the cards we printed early with the IDs, add
:::text load-module module-alsa-sink device_id=1 load-module module-alsa-sink device_id=2
Which is the equivalent of:
:::text * 1 is my NVIDIA GeForce GT400 HDMI output * 2 is my USB Audio Speakers
What you are going to do is put the device id we printed early. Usually I
avoid using 0 because dmix is probably using it already.
(Optional Step) In the occasion that you have a headset like me plugged in your on-board card.
load-module module-alsa-sink device_id=2
:::text load-module module-alsa-source device=hw:0,0
How can I find more capture devices?
$ arecord -l List of CAPTURE Hardware Devices card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 2: ALC887-VD Alt Analog [ALC887-VD Alt Analog] Subdevices: 1/1 Subdevice #0: subdevice #0
(Optional) Use Audacity to find more capture devices:
I noticed that Audacity lists all the devices with their respective hardware
numbers, like this:
Please don’t use pulse audio settings because you haven’t configured it yet.
*Take notice of “hw:0,0” or “hw:0,2”. *You can test which one works, that’s
the main idea behind using Audacity.
Remember to replace the device of module-alsa-source with the one that worked for you.
Next Step? Save the file and restart your system.
*Why restart your computer? I noticed while I was trying to figure out how pulseaudio worked that sometimes there would be a conflict in the modules. This would kill the sound completely and PulseAudio wouldn’t listen to me in the sense that no matter how many times I killed it, it wouldn’t start.
- In the original solution, we saw that the user wrote a local .asoundrc file. This is unneeded as you are making dmix become the default, so exporting extra variables is not needed. You can still use that type of solution to find creative ways of using your audio cards.
- I have moved the Audio Output source to my USB Speakers, Headset over and over and over to trigger the underrun. With the solution in place I’ve yet to run into an underrun problem
- The other solution would be removing pulseaudio completely, but if you have multiple cards you are going to suffer in terms of changing audio output source on the fly.
I hope this helped you. Feel free to leave a comment!