Applications routed through the pulse pcm alsa-plugin crackle/die quickly

Bug #485488 reported by Vadim Peretokin on 2009-11-19
This bug affects 30 people
Affects Status Importance Assigned to Milestone
alsa-plugins (Ubuntu)
Daniel T Chen

Bug Description

Binary package hint: pulseaudio

I'm assuming that ubuntu-bug adds all the technical information about my system, so I'll skip on that.

In short, on Jaunty - sound from game was fine on default settings.

On Karmic - sound 'crackles' at first, and then eventually just dies. No sound coming from game at all. Checking pavucontrol, it's not emitting any sound. Nothing changed with the game. The game will also hang on exit until I kill the games output stream in pavucontrol. ("the hang on exit is caused by snd_pcm_writei hanging (gets stuck in a blocking poll in libasound)")

Now, nobody really knows what's going on, so I'll just dump all that I know at first.

The problem is somewhere in the alsa<->PA layer.

Changing the games sound buffer to be 4*4096 fixed the problem for me ("what changes is that snd_pcm_hw_params_set_buffer_size_near gets passed a larger value")

It's affecting certain HDA Intel sound chipsets (not all HDA intel).

Mangler project says that the default latency changed:

There are many people on the games forum with this issue, although I can't give direct links as its in closed beta. But here are various things people have posted, that worked for some, and not for others:

Ubuntu forums thread regarding sound:

ProblemType: Bug
Architecture: amd64
 Card hw:0 'Intel'/'HDA Intel at 0xf8400000 irq 20'
   Mixer name : 'Realtek ALC268'
   Components : 'HDA:10ec0268,14c00025,00100003 HDA:10573055,10573055,00100700'
   Controls : 15
   Simple ctrls : 12
 Card hw:1 'Audio'/'Plantronics Wireless Audio Plantronics Wireless Audio at usb-0000:00:1d.0-1, fu'
   Mixer name : 'USB Mixer'
   Components : 'USB047f:d955'
   Controls : 4
   Simple ctrls : 2
Date: Thu Nov 19 15:26:11 2009
DistroRelease: Ubuntu 9.10
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release Candidate amd64 (20091020.3)
NonfreeKernelModules: nvidia
Package: pulseaudio 1:0.9.19-0ubuntu4
ProcVersionSignature: Ubuntu 2.6.31-14.48+ureadahead2-generic
SourcePackage: pulseaudio
Uname: Linux 2.6.31-14-generic x86_64

Vadim Peretokin (vperetokin) wrote :
description: updated
description: updated
Daniel T Chen (crimsun) wrote :

The culprit was a missing, incompatible change in alsa-lib's snd_pcm_hw_params_choose() that PulseAudio relies on. Because Karmic does not ship the changesets required, you're seeing pretty horrible performance. I've uploaded a staging version of alsa-lib with these fixes to the ubuntu-audio-dev PPA. Please test and verify that it resolves the issue for you.

affects: pulseaudio (Ubuntu) → alsa-lib (Ubuntu)
Changed in alsa-lib (Ubuntu):
assignee: nobody → Daniel T Chen (crimsun)
status: New → Fix Committed
charliehorse55 (evantandersen) wrote :

I can confirm this problem. Ubuntu 9.10 x64.

@ Daniel Chen

Whats the PPA, and how do I download it? (Sorry I'm new at linux)

Thanks, I'll give it a try.

@charliehorse55: it might be best to hold off testing if you're new,
in case something breaks. Best to wait until its available as an

I added that PPA, and upgraded the 2 asound packages, then rebooted.

The sound was OK until about 20mins into the game when it started getting choppyish. A detail I forgot to add - its its being chopping, it'll very quickly appear/dissapear in pavucontrol. This time I tried starting it, but then sound died when it opened. As usual, I had to kill the stream before it would restart - it froze otherwise.

Restarted game, was working alright for a bit but quickly died. At this stage of the game, more sounds are played I guess as there're more action going on.

Also, I found today that making it use ESD instead of Alsa works just fine.

charliehorse55, you can test that by doing ctrl+f8, "sound_output esd" and restarting the game.

charliehorse55 (evantandersen) wrote :

Yeah I added the PPA and updated those two packages, to similar results. trying ESD now...

description: updated
Vadim Peretokin (vperetokin) wrote :

Everything seems to be pointing to PA<->ALSA, as OSS and ESD are working in the programs that support alternatives. The fix from the PPA didn't work for me or charliehorse55 unfortunately.

Quite a problem as ALSA is the default on most sound-using applications that don't support PA directly...

Changed in alsa-lib (Ubuntu):
status: Fix Committed → Confirmed
description: updated
Daniel T Chen (crimsun) wrote :

Wait, are these libsdl-based games? If so, that's a bug in libsdl, and it has been fixed upstream in 1.2.14.

No, the one in question - Heroes of Newerth - isn't SDL based. It uses it's
own magic for display and fmod for audio.

I have this problem as well. I have Ubuntu 64 Bit 9.10.

Daniel T Chen (crimsun) on 2009-11-23
affects: alsa-lib (Ubuntu) → alsa-plugins (Ubuntu)
tomp (tompv11-toast) wrote :

Has anybody tried adding this...
to the end of this line in /etc/pulse/
"load-module module-udev-detect"
(remove the quotes)

It cured the problems I was having with my Creative Live card. It's basically the same as the "module-hal-detect" workaround for Jaunty.

Brian Vaughan (bgvaughan) wrote :

I don't know if I've got the same problem. I've been having trouble with occasional sound glitches and generally poor sound quality since the upgrade to Karmic. The sound glitch is most noticeable when hearing the brief bit of music after logging in via gdm -- it's as if the music is tripping over itself. In general, the music sounds as if it's coming through cheap speakers, with bad mixing.

I tried adding tsched=0, as tomp suggested. I think it helped with the sound glitches, but not the decreased sound quality.

Daniel T Chen (crimsun) on 2009-11-24
summary: - Game that uses ALSA's sound crackles/dies quickly in Karmic
+ Applications routed through the pulse pcm alsa-plugin crackle/die
+ quickly
WhyteHorse (whytehorse) wrote :

Chromium seems fine now. Glest is still having this problem.

Vadim Peretokin (vperetokin) wrote :

Any progress on this?

description: updated
Erwin (junkmail-hoefling) wrote :

The tsched=0 trick made it even worse for me... I can't use linphone (via alsa via pulseaudio) anymore since upgrading to Karmic.

The sound problems could be related to the reduced timer frequency of the Karmic kernel from 250 Hz to 100 Hz. Is there some competent person to assess this?

Raising the timer frequency seems to solve a completely different bug, which appeared since Karmic: virtualisation performance has degraded drastically. See

agent 8131 (agent-8131) wrote :

I am seeing this problem with The Battle for Wesnoth. I am currently fixing it by executing "killall pulseaudio" before running the game. I may simply remove pulseaudio until this and other problems are fixed.

Vadim Peretokin (vperetokin) wrote :

Yep, do that. It seems two months after, nobody is giving a damn about the major problems of sound on Karmic.

Durand D'souza (durand1) wrote :

I don't have this problem anymore on lucid.

On Mon, Jan 4, 2010 at 9:13 AM, Vadim Peretokin <email address hidden> wrote:
> Yep, do that. It seems two months after, nobody is giving a damn about
> the major problems of sound on Karmic.

Eh, "nobody is giving a damn" is a bit misleading. We all have other
priorities that trump this particular bug (yes, you may find it
unbelievable, but that's how things are set). So, in summary, just
hang on a bit while PA and ALSA devs trade debugging, okay?

Vadim Peretokin (vperetokin) wrote :

Okay :/

On Jan 4, 2010 10:16 AM, "Daniel T Chen" <email address hidden> wrote:

On Mon, Jan 4, 2010 at 9:13 AM, Vadim Peretokin <email address hidden>
wrote: > Yep, do that. It see...
Eh, "nobody is giving a damn" is a bit misleading. We all have other
priorities that trump this particular bug (yes, you may find it
unbelievable, but that's how things are set). So, in summary, just
hang on a bit while PA and ALSA devs trade debugging, okay?

-- Applications routed through the pulse pcm alsa-plugin crackle/die quickly

WhyteHorse (whytehorse) wrote :

I still have probs with GLest and have a 2 second delay when launching any audio. I mean the first 2 seconds of audio are cut off. This is with the default media player and all codecs like mp3, flash, etc.

I must admit things have improved dramatically and these are just minor annoyances but they do still persist. I don't consider the audio probs fixed in Karmic. I have no idea how to troubleshoot this further...

carthmen (carthmen) wrote :

Ok, I'm sure they are working on it. Maybe show some appreciation for all that they do for us instead of giving them attitude. They do a wonderful job! Especially given all there is to do with a full operating system while still living their lives and working jobs.

Here to all the great developers out there! *raises a beer*

ekilfoil (ekilfoil) wrote :

I'm the Mangler developer that first noticed the problem in the original ticket.

FWIW, something definitely changed between 9.04 and 9.10. The PA ALSA plugin used to deliver audio at a fairly low latency (low enough that the default worked for our needs). The newer version of PulseAudio increased this latency significantly (from about 0.1 seconds to about 2 seconds or so) in the simple API.

I don't know if it was intentional or not... it could very easily be a power saving measure to reduce CPU wakeups by the pulse daemon, but the result is horrible for ALSA apps that are expecting low latency.

I think there's two separate problems being described in this bug though. One is latency problems and the other is sound dropping (buffer problems). They're probably related, but are two different issues.

ekilfoil (ekilfoil) wrote :

Two other things:

1) PulseAudio's alsa plugin should honor the requested latency from the call to snd_pcm_set_params() by setting pa_buffer_attr.fragsize accordingly.
2) PulseAudio's alsa plugin should honor ALSA calls to snd_pcm_drain() -- which I think are most likely the cause of the audio cutoff when combined with the high latency.

David Henningsson (diwic) wrote :

Well, here is something to try out. I'll fix something more appropriate (git-send-email, debdiff, etc) in the next few days, right now I'm a bit to tired for the formalities. But I hope these three fixes should improve the situation.

+ /* Prevent accidental overrun of the fake ringbuffer */
+ if (size >= pcm->buffer_attr.tlength)
+ size = pcm->buffer_attr.tlength-1;

This cured a hang I could sometimes reproduce while recovering from an xrun.

+ writebytes = size * pcm->frame_size;
+ ret = pa_stream_write(pcm->stream, buf, writebytes, NULL, 0, 0);
+ pcm->last_size -= writebytes;

This updates the hw_ptr variable correctly, which fixed some continous xruns for me as well as reduced CPU usage.

+ /* Reset faked buffer */
+ pcm->last_size = 0;
+ pcm->ptr = 0;
+ update_ptr(pcm);

Before prepare is called the ioplug interface resets its pointers, so we should do the same. No real difference in experience from this one, it just seems reasonable.

Daniel T Chen (crimsun) wrote :

On Thu, Jan 7, 2010 at 9:49 PM, David Henningsson
<email address hidden> wrote:
> Well, here is something to try out. I'll fix something more appropriate

Is this still necessary given Jaroslav's latest pcm lib+core changes?
I've merged them into Lucid's latest alsa-driver upload, and you can
use the alsa-source binary package to test.

David Henningsson (diwic) wrote :

@Daniel: I haven't tested yet, but I just had a quick look at hwptr_pcm_io_fixes.patch and it doesn't look like it is affecting my patch. Possibly either patch reduces CPU usage.

David Henningsson (diwic) wrote :

Ok, now I have backported my fix to Karmic and at least is seems to improve the situation for me there, it would be nice if you people following this thread could help me test it!

To test it, install the alsa-plugins package from my ppa:

theqat (theqat) wrote :

@David: As far as I'm concerned, you're a miracle worker--my sound in HON seems to work perfectly now, and you somehow fixed my loading time problem too.

Using both ubuntu-audio-dev and David PPA's and updating seems to do the trick for me...

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package alsa-plugins - 1.0.22-0ubuntu2

alsa-plugins (1.0.22-0ubuntu2) lucid; urgency=low

  * lp485488.patch: Update ptr calculation to be consistent with changes
    made to pcm core+lib since linux 2.6.27. Thanks, David Henningsson!
    (LP: #485488)
 -- Daniel T Chen <email address hidden> Fri, 08 Jan 2010 22:25:51 -0500

Changed in alsa-plugins (Ubuntu):
status: Confirmed → Fix Released
David Henningsson (diwic) wrote :

I'm afraid I'll have to adjust my patch. Playback improves, but recording breaks.

Daniel T Chen (crimsun) wrote :

On Sat, Jan 9, 2010 at 1:24 AM, David Henningsson
<email address hidden> wrote:
> I'm afraid I'll have to adjust my patch. Playback improves, but
> recording breaks.

That's fine (and why I haven't pushed it upstream yet).

David Henningsson (diwic) wrote :

Seems like the recording problem was as simple to fix as I suspected...

David Henningsson (diwic) wrote :

I have now updated my ppa with a version that improves recording as well. Please test it.

Guy Moreau (gmyx) wrote :

This patch works for me as well. Thank you very much. I haven't seen any issues yet.

WhyteHorse (whytehorse) wrote :

I tried this PPA but I still get sound dying in GLest and a 2 sec delay when launching a music file in totem. It only has the delay the first time I run it after booting up. Perhaps my issue is with the Totem Movie Player 2.28.2 using GStreamer 0.10.25 during initialization because if I close the app and then play another song it has no delay... Perhaps pre-cache is not working as designed or my system is hosed?

I can't tell if the system is using less cpu now but I just upgraded to kernel 2.6.31-17-generic and the system now balances cpus properly and screams along even if I'm playing music, flash, etc.

Overall can't complain except for GLest not playing sounds after about 2min and playing the snap-crackle-pop just before dying followed by slight crackles every time a sound event is generated.

David Henningsson (diwic) wrote :

@Whytehorse: thanks for testing. However, Totem -> GStreamer -> Pulse and GLest -> OpenAL -> Pulse - none of those paths should include the ALSA plugin, so they are not affected by this patch.

Darkalia (darkalia-koulmir) wrote :

Used the fix for a couple of day now, and no issues so far.

Sounds which cracked at game start or sometimes after a little use of several sound application does not appear anymore (VLC+Heroes of Newerth + Rhythmbox, most of the time)

I keep you posted if something strange occurs.

reduz (reduzio) wrote :

I'm trying this out in hopes of a fix too. I hope everyone realizes that the many layers of complexity that exist now on linux audio world are evidently making everything increasingly difficult to mantain... since pulseaudio has been made default in ubuntu, i've been having problems with it on every machine i have.. from PA constantly crashing and leaving me with no sound, to crazy 100% CPU usage peaks, and now this. Yes I know those bugs are now fixed, but it can't be denied that they did happen due to having an extra layer! I used to install OSS4 to solve all my issues, but now Gnome in ubuntu 9.10 does not even support that (mixers just stop working).

Erik (ubuntu-erikdokter) wrote :

Using David's alsa-plugins package (libasound2-plugins), playback works but recording still is cracked when using TeamSpeak 3 beta 12. I set the Capture Mode to ALSA and Capture Device to 'default'. I then changed the capture (and playback) device via pavucontrol to the desired device.

Using Linux 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 17:01:44 UTC 2009 x86_64 GNU/Linux

Erik (ubuntu-erikdokter) wrote :

Lol, I feel stupid |:( Installing the new pulsaudio package which was released today (pulseaudio 1:0.0.19-0ubuntu4.1) and rebooting has fixed the problem.

Many thanks :)

I installed the new pulsaudio and alsa and it made my glitchy sound even worse.
Have been using mangler and HoN concurrently and HoN completely dropped off then mangler sometimes following suit.

Changed my sound settings for both applications so they used the internal audio and touch wood everything is working.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.