Notice: Thank you for using this how-to. I never expected it to bring in so many people with audio issues. I want to say that this guide is gonna be deprecated soon in the future. I feel like the dmix solution is not good enough; I’ve been testing with JACK Audio Connection Kit to bring a more formidable solution, however doing long term testing takes time. Plus I’ve run into issues with the native version of Steam client… so you can guess on why I haven’t posted anything about the new solution.

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
in /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 ~/.pulse/default.pa or ~/.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:

locate default.pa

As you have noticed I use KDE, so I’ll be using Kate text editor to open
my configuration files.

Important Notes:

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.

First Step:

We are going to check how many soundcards your system detects. For this we
will do the following command

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

Then

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
picture.

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

(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.

Side notes:

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.

Hello. I run into this problem every time I try to run any game with PlayOnLinux/wine and tried your solution. It did not work and I am not experienced enough to know whether this is something easy and obvious to fix and does not help you or it’s something common which should be included in the guide. So I’ll leave what I have here. Any help/reply is of course welcome, hope this helps in some way regardless.

What happened:
Followed your guide, ignored the stuff about headsets. After reboot there’s no sound, pulseaudio is not running. Started pulseaudio from console. Seems that “load-module module-alsa-sink device=dmix” already doesn’t work.

thanks for the reply. Sorry for the wall of text, didn’t realize it would be that much.

Here’s the file I used. I also tried some combinations of uncommenting the lines 47-49 (especially with all of them uncommented and 48 and 49 uncommented). The original file is the same as this one, just with line 46 commented and line 60-65 uncommented:https://bpaste.net/show/d95117bf73fd

I tried the configuration in my laptop and it works. Why it behaves like that it could be:

PulseAudio may be running system-wide? (that’s a no-no).

Something is grabbing hw:0 as a resource before pulseaudio. (see first option, it could conflict, and I really doubt this is the case)

You are not in the audio (in fact, you SHOULD NOT be in this group when PA is running) or pulse group. In this time and age this shouldn’t be necessary anymore, but well different distributions means different defaults.

You have an ALSA configuration that might interfere with PulseAudio.

Your PulseAudio previous configuration is trying to remap itself to devices that “no longer are there” since you chose dmix. You could try removing the folder ~/.config/pulse, no harm done.

Install pavucontrol sudo apt install pavucontrol and if it opens and let’s you configure ports in output devices/etc.

I think, it’s not much about not recognizing the device but that’s trying to configure itself to something that’s no longer there: