Playback glitching with ALSA


I'm getting glitchy / choppy audio output from some of the JUCE example projects.  I'm running up-to-date Arch Linux (kernel 3.18.2-2) and I have the JUCE source from git, current as of today (commit 0401.)  I noticed this glitchiing while running the Audio Plugin Host, but I also hear it in the Demo project (e.g. Synthesizers, File Playback) and BouncingBallWavetableDemo.

In Demo, if I increase the buffer size (e.g. between 512 and 4096) the glitching gets slightly slower and steadier, from many dropouts per second (maybe >10) to more like one per second.

Qualitatively the audio glitches sound like what's described here:
However, it sounded like that poster's problem was specific to pulseaudio, whereas I don't have pulseaudio installed and am just using ALSA.

Any ideas, or other information I can provide?
Thank you!



Very hard to debug ALSA things like this without actually having the same device (and system) to test myself. ALSA devices seem to vary a lot in their behaviour.. All I can suggest is maybe running a profiler or debugging into the low level code to try to narrow down the area that's causing trouble. Happy to do what I can if you have any more clues..


Hi Jules, thanks for the reply.  Unfortunately I do not yet have any ALSA log data (incidentally this seems surprisingly difficult, depending on certain kernel flags which are not set on my Arch system  So I'll understand if this still isn't enough data to help, but I did notice a new detail: the glitching goes away (including at small buffer sizes e.g. 64) if I have only audio outputs, and no inputs, active.  (I observed this using the Demo app (Settings + Synthesizers demos) but I've also written several small JUCE programs that use only audio output and work fine on my system.)


Hmm, that's interesting. Because the inputs and outputs are separate, there's some nastiness in the ALSA wrapper to try to synchronise them, and that could be the culprit in cases where the input and output devices have a tendency to drift. I'll try to have a look into this..


I also find that I turn off the output [edit: I meant turn off the input] the glitch goes away.  I was the original poster on the Scientific Linux post and it did appear to be pulseaudio at the time.  The glitchiness was very occasional, so it was hard to determine if pulse was the cause - esp with all the popular discontent with pulse architecture etc. 

But since then I have gotten this bad playback to happen with pulse completely disabled, both with the Juce Demo and my own code.  Shutting off the input seems to make it go away.  My current users don't need to record, so I can disable it in my app, but it would be nice to finally resolve this issue.




Has anybody made any progress with this? I noticed that the problem seems to go away if I run JUCE at a sample rate of 44100, but it occurs if I run it at 48k.