I'm using the latest AudioKit (5), and have got it to pretty much work to my liking on the device simulator. Issue is that on my physical device (iphone x / ios 14), the engine.start() is failing.
General logic on viewDidAppear:
private func startEngine() {
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playAndRecord)
try engine.start()
} catch let err {
print("START ENGINE FAILED: ", err)
}
}
Output:
Error Domain=com.apple.coreaudio.avfaudio Code=-10875 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInOutputChain(ThisGraph, kOutputChainOptimizedTraversal, *GetOutputNode(), isOutputChainActive)}
Would appreciate any help / ideas about this!
Thanks
Apparently my session wasn't active and set to the correct playback mode.
It is important to do so on appDidFinishLaunching or way before you expect to show your recording/playback screen.
do {
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
try AVAudioSession.sharedInstance().setCategory(.playAndRecord)
} catch(let error) {
print(error.localizedDescription)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With