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
Hubro
  • 1,283
  • Maybe related or duplicate: https://askubuntu.com/questions/124602/all-sounds-that-come-out-of-wine-are-distorted-with-buffer-underruns – donquixote Apr 23 '14 at 03:24

6 Answers6

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/

Iskren
  • 341
  • 2
  • 5
  • 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 06 '14 at 07: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 '14 at 08: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? – dr Hannibal Lecter Sep 01 '14 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: http://arunraghavan.net/2013/08/pulseaudio-4-0-and-skype/ – Iskren Sep 03 '14 at 06:24
  • I'm afraid this solution doesn't work in POL. Though, at first, it appeared to. – Tamsyn Michael Dec 06 '15 at 02:26
  • Not helping for me with PlayOnLinux + Scarcraft II. – donquixote Dec 18 '15 at 16:54
  • I believe the pulse setting is the solution, but the above alias has no effect on PlayOnLinux. – donquixote Dec 18 '15 at 16:55
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.

DeeJayh
  • 378
  • 1
  • 4
  • 17
  • 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 '13 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 '13 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 '13 at 01: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 '13 at 01: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. – Jonathan Baldwin Mar 27 '15 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
kos
  • 35,891
Skitz
  • 31
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.

allenskd
  • 1,278
  • 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 '14 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...) – Jonathan Baldwin Mar 27 '15 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

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