I'd like to understand the most robust way to record audio to disk using AVAudioNode
s installTap(onBus:bufferSize:format:block:)
method.
Currently, I'm dispatching out the buffers I receive in my AVAudioNodeTapBlock
to a serial dispatch queue then writing to disk using some Audio Toolbox methods, but my concern is that if I hold on to the buffer provided in the AVAudioNodeTapBlock
for too long (due to disk I/O for example), I'll end up getting issues.
What I'm considering is creating my own larger pool of preallocated AVAudioPCMBuffer
s (a few seconds worth) and copying across the data from the buffer provided by the tap into one of the buffers from this larger pool in the AVAudioNodeTapBlock
directly (no dispatch queue).
Is there a simpler way of handling this, or does this sound like the best route?