In my app I do recording and play recorded sound right away:
func finishRecording(success: Bool) {
audioRecorder.stop()
audioRecorder = nil
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(AVAudioSessionCategoryAudioProcessing)
try audioSession.setActive(false)
playSound(url: audioFilename!)
...
func playSound(url : URL) {
do {
let engine = AVAudioEngine()
let newPlayer = AVAudioPlayerNode()
engine.attach(newPlayer)
let mainMixer = engine.mainMixerNode
The last line prints an error: ERROR: [0x1a07d0000] >aurioc> 807: failed: '!cat' (enable 2, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
As I understand this error happens because input node is still in use. I'm not sure what should I do to set it free to be able to initialize AVAudioPlayerNode with mainMixerNode?
(If I kill the app and play recorded sound with my play func it works correctly)