Glitchy Live Input Audio
I’m working on an app which uses GPUImage for video recording/filtering, AVFoundation for video playback, and AAE2 for audio recording and playback. Although CPU usage often sometimes hovers above 50%, performance for the app is generally solid. I’m able to simultaneously record video and audio, then perfectly sync up the recorded media by setting the video player’s master clock to the system audio clock, and then using AVPlayer’s setRate:time:atHostTime.
All works well except for the case where live input monitoring is enabled (which is automatically the case when the user has headphones plugged in). When recording is started, the microphone input becomes distorted / glitches for about half a second. The resulting audio recording contains the glitch, although when recording audio and video without live audio input monitoring the resulting audio is typically glitch-free. The problem also arises when only recording video while audio input monitoring is enabled.
This leads me to believe the onset of video recording is so demanding that there’s not enough CPU to simultaneously process and pass through the live microphone input, hence the glitch.
Any ideas for how to solve this or directions to point me in?