I have the iOS app where I play audio using AVAudioEngine. I read frames from AudioFile to AVAudioPCMBuffer and then I add buffer to AVAudioPlayerNode.scheduleBuffer. I read frames on DispatchQueue. The problem I have is that when the app has a lot of work to do – synchronizing with the server and downloading the file, reading frames on the DispatchQueue are run with a few seconds delay, causing audio interruptions.
I have set DispatchQueueQos to the highest possible .userInteractive and I have no other queues with the same qos in the app, but sometimes it takes a few seconds to execute code on that queue.
Is there any solution to this? Any way to tell us that this queue is for sound or something similar?
Note: I do not have this problem with AVPlayer if the app runs some heavy background operations.