14

Sounds in my applications are played in super speed and are crackling horribly. In Spotify, the songs are actually playing at around 3x speed. I have Googled this quite a bit and all I can come up with is a bug report from January 2012 which is marked as closed.

I have tested Spotify and Hearthstone using PlayOnLinux with Wine versions 1.5.0, 1.6, 1.6.0, 1.7.0, 1.7.8 as well as the system Wine which is version 1.4.1. They all have the exact same terrible crackling sound issue. This leads me to assume that this is not a bug with Wine.

The steps to reproduce from the bug report:

Steps to Reproduce:
1. winecfg
2. go to Audio tab
3. Test Sound

Actual results:
crackling sounds produced

Expected results:
normal output

Are also producing crackling noises for me. While doing it, winecfg printed the following to the terminal:

p11-kit: couldn't load module: /usr/lib/i386-linux-gnu/pkcs11/p11-kit-trust.so: /usr/lib/i386-linux-gnu/pkcs11/p11-kit-trust.so: cannot open shared object file: No such file or directory
err:ole:CoInitializeEx Attempt to change threading model of this apartment from multi-threaded to apartment threaded
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred

(The first line showed up as I opened winecfg, the last 5 showed up when I clicked Test Sound)

Any clues what could be wrong? Let me know if I can provide any more information.


pulseaudio 1:4.0-0ubuntu6 amd64
1

6 Answers 6

24

Since this is the first result returned by Google, I'd thought I share my experience here. For those who look for a quick fix, put the following in your ~/.bashrc or /etc/profile for system-wide change:

alias wine='PULSE_LATENCY_MSEC=60 wine'

This is the same fix that's used for Skype and PulseAudio 4.0 and above, which is behaving the same way as wine. Hope this helps!

Edit (12.01.2016):

You can enable this variable globally by adding this line to ~/.bashrc and logging out/rebooting

export PULSE_LATENCY_MSEC=60

If you're experiencing audio issues in other applications after this, simply delete the line and logout or reboot. If you want to test it temporarily, open a new terminal and paste that line. Now every application that you invoke from this terminal will have the variable set and PulseAudio will set the latency.

More information on this problem and the 'fix': http://arunraghavan.net/2013/08/pulseaudio-4-0-and-skype/

7
  • Does this also work when starting wine from PlayOnLinux and similar applications? I'd test, but I don't know how to confirm the results...
    – Hubro
    Jun 6, 2014 at 7:08
  • 1
    No idea, never ran PlayOnLinux. You can test it by typing the above command in a terminal and run something from PlayOnLinux. If your sound is fine, then it's working. If it's not, you can try setting the variable directly by running "export PULSE_LATENCY_MSEC=60" in a terminal and then running PlayOnLinux from the same terminal. It will "inherit" the variable and it should work.
    – Iskren
    Jun 18, 2014 at 8:39
  • Saved my bacon. I was having this problem for years, this is the only thing that worked. I am curious though, do you remember where you got this solution from? Do we know why does it work? Sep 1, 2014 at 10:02
  • I had issues with PA4 and Skype a while back and was searching for a solution. A bit later wine started doing the same so I just gave the skype fix a try and it worked. This post explains quite well what the problem is and how this variable fixes it: arunraghavan.net/2013/08/pulseaudio-4-0-and-skype
    – Iskren
    Sep 3, 2014 at 6:24
  • I'm afraid this solution doesn't work in POL. Though, at first, it appeared to. Dec 6, 2015 at 2:26
8

Run a terminal (Ctrl+Alt+T)

Issue command pulseaudio -k

Try to recreate issue. Shouldn't play in fast forward anymore.

As to the crackling the log tells you plain and simple, you have a buffer underrun. Change your sampling quality... Sacrifice some quality for speed and see if that solves your underrun.

5
  • I got up this morning and was unable to recreate the issue. Sounds play perfectly now. The only thing I have done since yesterday is switch the sound output from my headset to HDMI. Today I switched back and the crackling is gone. It will probably happen again soon though, I'll try to kill pulseaudio then.
    – Hubro
    Dec 19, 2013 at 20:31
  • The issue returned. I tried pulseaudio -k and all sound disappeared. The sound slider on Ubuntu is grayed out and there are no sound devices in the sound options. Had to reboot to get sound back.
    – Hubro
    Dec 19, 2013 at 22:19
  • Pulse audio should restart on it's own, next time you have an issue try sudo alsa force-reload
    – DeeJayh
    Dec 20, 2013 at 1:15
  • Also just issuing the command pulseaudio should start it back up for you when it doesn't on it's own.
    – DeeJayh
    Dec 20, 2013 at 1:17
  • It's not a CPU bottleneck. I have the same issue on a 4790k with World of Warcraft, I never go above 30% CPU and I have the nice on WoW and Pulseaudio set to -20. Something in software is preventing pulseaudio from actually filling the buffers. Mar 27, 2015 at 21:55
3

With certain games if you use PlayOnLinux you can open the launcher with your text editor and change the Exec= line as follows:

Exec=env PULSE_LATENCY_MSEC=60 /usr/share/playonlinux/playonlinux --run "GameName" %F
1

Try this solution. It mostly had to do with PulseAudio, personally I removed it and tried it again and the underrun was gone, but I lost the ability to move audio output to different sinks. This how-to maintains pulseaudio and ALSA play nicely with each other without letting pulseaudio hog the hardware directly.

2
  • 3
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Stormvirux
    Mar 16, 2014 at 14:07
  • It's not a solution for anyone that needs to record audio coming from a Wine application, or that gives the slightest care to latency whatsoever (Pulse plays fast and loose enough with latency as it is, but throwing dmix in there too...) Mar 27, 2015 at 21:53
0

Added an updated solution as above to

http://tux-is-gaming.blogspot.com.au/2014/02/fixing-alsa-lib-pcmc7843sndpcmrecover.html?showComment=1394964710443#c3501258764752400662

2
  • 2
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Stormvirux
    Mar 16, 2014 at 11:25
  • 1
    Agreed but it's just a small tweak I added (see comment at bottom) to a quite well described fix on the url provided Mar 16, 2014 at 13:42
0

After running just fine a portaudio application started sounding erratic while shooting errors

ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred

SOLUTION - first you need to kill the existing process ... issue these cmds

    pulseaudio --kill

    jack_control start

Once you are done with the above then issue these commands :

    jack_control exit

    pulseaudio --start

Now same application then played audio via portaudio just fine

cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"

dpkg -l|grep portaudio
ii  libportaudio2:amd64                         19+svn20140130-1build1                               amd64        Portable audio I/O - shared library
ii  libportaudiocpp0:amd64                      19+svn20140130-1build1                               amd64        Portable audio I/O C++ bindings - shared library
ii  portaudio19-dev                             19+svn20140130-1build1                               amd64        Portable audio I/O - development files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .