Post

Replies

Boosts

Views

Activity

Reply to AVAudioPlayerNode crash (no IO cycle)
This was happening to me as well when I had bluetooth connected to iPhone, but was not preferred device in any way. I received crashes with: player did not see an IO cycle. I encountered this because I used setVoiceProcessingEnabled function on input node same as mgarabed7. This was my solution in case anyone runs into this problem again. I kept bumping into this problem and was rarely connected to bluetooth so it took me a while to figure it out. In my app I record and playback audio from microphone at the same time, so I use input and output. // Define this somewhere let engine = AVAudioEngine() // ... // Capture current active device, if you want to specify any other device thats fine too. let audioSession = AVAudioSession.sharedInstance() let activeInputDevice = audioSession.currentRoute.inputs.first.map { .fromAVSessionPort(port: $0) } // -- Generally here you can expect various combinations, such as built-in microphone as input and speaker or even nil as output. // or perhaps even bluetooth as input and output. // Enable voice processing to prevent microphone from picking up feedback from speakers. try engine.inputNode.setVoiceProcessingEnabled(true) // -- When bluetooth device is connected, active device (first route input) is no longer the same, bluetooth has taken over. // -- return to original state. No category or mode helped here, tried them all. // Set previously active device as preferred device. And it no longer crashes. if let activeInputDevice = activeInputDevice {   try audioSession.setPreferredInput(activeInputDevice) }
Aug ’22