Looking closer at the debug memory graph it seemed that the autoreleasepool holding the audio buffer was too long-lived. I've not worked closely with these pools before but I was able to solve the memory issue by closely wrapping the conversion call in its own pool:
_ = autoreleasepool {
converter.convert(
to: outputBuffer,
error: nil,
withInputFrom: converterInputBlock
)
}
This appears to correctly scope the lifetime of the buffers. If anyone has a good explanation for this I'd love to hear it!
Topic:
Media Technologies
SubTopic:
Audio
Tags: