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

3

6

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?

Scotticism answered 13/7, 2017 at 7:32 Comment(0)
S
5

https://www.osstatus.com/search/results?platform=all&framework=all&search=-50

I found the link just now. You can see all the error code of apple coding

Scotticism answered 13/7, 2017 at 7:40 Comment(0)
O
4

I didn't find the exact description of the error but it seems to be a generic "invalid parameters" exception.

In my case, and very likely in your case too, the issue was a mismatch between the buffer and the format of the AVAudioFile instance.

let settings: [String: Any] = [
    AVFormatIDKey: kAudioFormatLinearPCM,
    AVSampleRateKey: 44 * 1000,
    AVNumberOfChannelsKey: 2
]

do {

    try avFile = AVAudioFile(forWriting: URLFor(filename: "test.caf"), settings: settings)

    avEngine.inputNode?.installTap(onBus: 0, bufferSize: 1024, format: avEngine.mainMixerNode.outputFormat(forBus: 0)) {
        buffer, time in

        do {
            try self.avFile?.write(from: buffer)
        }
        catch {
            // TODO
        }

    }

    try avEngine.start()

} catch  {
    // TODO
}

In the example below I was getting the "-50" error when I created the AVAudioFile in any format other than PCM, 2channel 44khz.

Overstay answered 13/9, 2017 at 4:5 Comment(0)
B
0

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
])
Bergerac answered 18/6, 2020 at 16:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.