Urgent! Audio glitches on Samsung S9+

SOLVED! Now rendering to a circular buffer which is then consumed by getNextAudioBlock. No glitches at all on device no matter what I do.

Hi guys! I am currently working on a generative music library which works really well on mac and iOS. It works pretty well in Android Emulator (Pixel 3) but when running on a Samsung S9+ the audio goes from barely acceptable to complete rubbish.

It seems to get worse when not constantly touching the screen, but even when touching the screen it is very unstable. I am using Juce 5.4.6 with Oboe 1.3. I have tried all I can think of. I have modified juce_android_Oboe.cpp to use stabilizedCallback and I have verified that it is being used. C/++ optimization set to -Ofast.

I have tried busywaiting to keep CPU spinning. I have tried WakeLock’s. I have set FLAG_KEEP_SCREEN_ON. I have set thread priority to THREAD_PRIORITY_URGENT_AUDIO. I even tried creating the basic audio app template in projucer and had it output a simple sine wave. Even that is glitchy and unstable. I don’t really need short latency, so maybe that could present a solution?

Now, I have seen other posts about this, but I haven’t seen a solution. So, please let me know how to proceed. This is pretty urgent and we are about to purchase a JUCE license really soon, but if it turns out we can’t use it on Android, we may have a problem.

Anyone have a clue?

Never mind! I solved it and it now runs 100% glitch free on the device.