There’s a strange latency with audio output happen in my app, when it uses Juce’s audio framework. I was initially using PortAudio library and the latencies there were strictly dependent on the audio buffer size set, what is normal. But after switched to JUCE, I discovered, that the resulting latency is twice longer than should be according to the current buffer size! I checked several times with different buffer sizes to be sure, and yeah, its around two times longer (but not exactly two times - with big buffer sizes it becomes even longer). I of course accurately checked and debugged all this to ensure that everything is okay in data.
It also looks like this delay somehow depends on audio callback nature. I tried another test on it - replaced my callback with another, that generates random noise if a trigger button is pressed and silence if not pressed. No such a big latency happen then and everything is okay, but when I use my usual callback, it does such latency independently on how much data is processed - even if a single sample is playing, the latency is the same. That’s why I’m saying it somehow depends on callback nature, not on its speed. Anyway, if the callback’s speed were the problem, there would be another result of it - buffer underruns, clicks etc, but not latency. And as I said, with PortAudio everything is okay even now, when I switch compilation defines to use PortAudio.
I tried out Juce Demo app and saw similar big latency there, but only in debug mode, when compiled it myself from sources. In release mode everything is all right. But in my app the latency absolutely the same both in debug and release builds. Quite weird, isn’t it? I also transitioned from 1.46 to 1.50 version, but this didn’t fixed the problem.
Any thoughts or suggestions on this are welcome. Thanks in advance.