How to search the error code of 'com.apple.coreaudio.avfaudio'?

Viewed 3743

Where could I get the information of com.apple.coreaudio.avfaudio error codes, such as:

Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -50'

I always get an error while writing PCM buffer to AVAudioFile. The buffer comes from AVAudioEngine's output node.

enter image description here

The error:

* Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -50' * First throw call stack: (0x18eb46fe0 0x18d5a8538 0x18eb46eb4 0x1a8d051cc 0x1a8d731dc 0x1000d45e0 0x1000d4820 0x1a8d14654 0x1a8d146c0 0x1a8d8c26c 0x1a8d8c1fc 0x100ae5a10 0x100af1a84 0x100b001f8 0x100ae7a60 0x100af3128 0x100ae9634 0x100af5630 0x100af6f48 0x18dc0968c 0x18dc0959c 0x18dc06cb4) libc++abi.dylib: terminating with uncaught exception of type NSException

Could you help me?

3 Answers

I had a similar issue, where I was getting a com.apple.coreaudio.avfaudio -50 error with mismatched sample rates. I just had to set the AVAudioFile to match the mainMixerNode outputFormat.

let format = engine.mainMixerNode.outputFormat(forBus: 0)

self.musicTrackFinalOutputFile = try AVAudioFile(forWriting: temporaryFileURL, settings:  [
    AVFormatIDKey: NSNumber(value:kAudioFormatMPEG4AAC),
    AVEncoderAudioQualityKey : AVAudioQuality.high.rawValue,
    AVEncoderBitRateKey : 320000,
    AVNumberOfChannelsKey: format.channelCount,
    AVSampleRateKey : format.sampleRate
])
Related