简体   繁体   中英

AudioKit engine failing on physical device Error Domain=com.apple.coreaudio.avfaudio Code=-10875

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)
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM