I have an application based on Juce that already runs fine on Windows and OS X and I am trying to make it run on Linux distribution, on a Raspberry Pi 2 (I am currently trying on a Debian).
I want to use it with an USB Audio Class 2 device. The application opens input and output channels as well (it has to run fine on 6 channels).
The problem on Linux is that after a while the sound becomes distorted. It plays fine for some time (from a few seconds to a few minutes and then the sound becomes distorted). I also tried with a simple app (let's call it DEMO) which contains only an AudioDeviceSelectorComponent where I route the input to output and I have the almost the same result. The difference is that the sound is more stable (distorsion appear later). The problem does not seem to be related to the audio buffer size. With DEMO I can play fine for over an hour with 96000Hz and 256 samples buffer and I can hear distorsion after just a few seconds with 48000Hz and 512 samples buffer.
The problem seems to me to be somehow related to CPU usage. I tried with 3 apps: my full application, my application without gui (but does the whole processing part) and that DEMO. With applications that take more CPU, the sound becomes unstable sooner (my full app - gui and processing - runs fine from only a few seconds to a few tens of seconds while my app without gui can run fine up to an hour with 5ms buffers). However, with the same application, things are confusing. With a smaller buffer (which implies higher CPU usage) the app can run better than with larger buffers.
I also tested my app on a laptop running Ubuntu 14.04 and I get the same results (with the difference that the apps can play fine longer until the distorsion appear).
I noticed that while the sound is distorted, if I change device parameters (sample rate or buffer size) the sound becomes normal (for an amount of time, but distorsion appears again after a while).
ALSA does not report any xrun while this is happening (at least this is what I think, I put 3 in /proc/asound/<mycard>/pcm0p(c)/xrun_debug and I see nothing in the logs) and the signal is already distorted when I read it from the input buffer.
If someone has any clue on how to debug this or what can I try to fix this problem please let me know.