簡體   English   中英

iOS13 崩潰 - 錯誤:無法在浮點轉換器 ('insz') 中填充復雜緩沖區

[英]iOS13 Crash - Error: Failed to fill complex buffer in float converter ('insz')

我正在使用這樣的 AudioKit 4.8

class AudioKitWrapper {

    /// The main output mixer (after the amplitude tracker)
    private let masterMixer:  AKMixer

    /// The audio input
    private var microphone:   EZMicrophone?

    /// Construction
    init() {
        // global settings
        AKAudioFile.cleanTempDirectory()
        AKSettings.defaultToSpeaker = true
        AKSettings.enableRouteChangeHandling = true
        AKSettings.enableCategoryChangeHandling = true
        AKSettings.disableAVAudioSessionCategoryManagement = true
        AKSettings.audioInputEnabled = true
        AKSettings.playbackWhileMuted = false
        #if DEBUG
            AKSettings.enableLogging = AppConfig.AudioConfig.debugLogEnabled
        #endif
        // main mixer
        masterMixer = AKMixer()
    }

    /// Start up audiokit
    func startEngine(with audioInput: Bool) throws {
        // connect main nodes
        AudioKit.output = masterMixer
        // input
        microphone?.delegate = nil
        microphone = nil
        if audioInput {
            AKSettings.enableEchoCancellation = true
            let sizeOfFloat = UInt32(MemoryLayout<Float>.stride)
            microphone = EZMicrophone(microphoneDelegate: self,
                                      with: AudioStreamBasicDescription(mSampleRate: Float64(mirgaFactory.getSampleRate()),
                                                                        mFormatID: kAudioFormatLinearPCM,
                                                                        mFormatFlags: kLinearPCMFormatFlagIsFloat |
                                                                                      kAudioFormatFlagsNativeEndian |
                                                                                      kAudioFormatFlagIsPacked |
                                                                                      kAudioFormatFlagIsNonInterleaved,
                                                                        mBytesPerPacket: sizeOfFloat,
                                                                        mFramesPerPacket: 1,
                                                                        mBytesPerFrame: sizeOfFloat,
                                                                        mChannelsPerFrame: 1,
                                                                        mBitsPerChannel: sizeOfFloat * 8,
                                                                        mReserved: 0),
                                      startsImmediately: false)
        }
        // start
        try AKSettings.session.setCategory(.playAndRecord, mode: .measurement, options: .defaultToSpeaker)
        try AudioKit.start()
        microphone?.startFetchingAudio()
        Log.d("~~~ AudioKit: started")
    }

    /// Stop engine
    func stopEngine() throws {
        try AudioKit.stop()
        microphone?.stopFetchingAudio()
        Log.d("~~~ AudioKit: stopped")
    }

    /// Attach output
    func attach(audioPlayer: AKAudioPlayer) {
        audioPlayer >>> masterMixer
    }

    /// Reset
    func reset() {
        masterMixer.detach()
        Log.d("~~~ AudioKit: reset")
    }

}

/// Handle EZMicrophone input
extension AudioKitWrapper: EZMicrophoneDelegate {

    /// Playing state changed
    func microphone(_ microphone: EZMicrophone!, changedPlayingState isPlaying: Bool) {
        Log.i("playing state - \(isPlaying)")
    }

    /// Device changed
    func microphone(_ microphone: EZMicrophone!, changedDevice device: EZAudioDevice!) {
        Log.i("device - \(String(describing: device))")
    }

    /// Audio stream description
    func microphone(_ microphone: EZMicrophone!, hasAudioStreamBasicDescription audioStreamBasicDescription: AudioStreamBasicDescription) {
        Log.i("stream - \(audioStreamBasicDescription)")
    }

    /// Input buffer handling
    func microphone(_ microphone: EZMicrophone!,
                    hasAudioReceived buffer: UnsafeMutablePointer<UnsafeMutablePointer<Float>?>!,
                    withBufferSize bufferSize: UInt32,
                    withNumberOfChannels numberOfChannels: UInt32,
                    atTime timestamp: UnsafePointer<AudioTimeStamp>!) {
        writeSamplesIntoCircularBuffer(buffer[0]!, bufferSize, timestamp)
    }
}

iOS13 - iPhone7

它與此日志一起崩潰

2019-10-11 09:37:01.917118+0200 WyntonHost[555:135079] AUBuffer.h:61:GetBufferList: EXCEPTION (-1) [mPtrState == kPtrsInvalid is false]: ""
2019-10-11 09:37:01.938441+0200 WyntonHost[555:135079] AUBuffer.h:61:GetBufferList: EXCEPTION (-1) [mPtrState == kPtrsInvalid is false]: ""
Error: Failed to fill complex buffer in float converter ('insz')

Process finished with exit code 255

iOS13 - iPadAir2

我在沒有崩潰的情況下收到此日志消息(我假設每個音頻幀有數百條)

2019-10-11 09:34:07.187762+0200 WyntonHost[376:18541] AUBuffer.h:61:GetBufferList: EXCEPTION (-1) [mPtrState == kPtrsInvalid is false]: ""
2019-10-11 09:34:07.211279+0200 WyntonHost[376:18541] AUBuffer.h:61:GetBufferList: EXCEPTION (-1) [mPtrState == kPtrsInvalid is false]: ""

iOS12 - iPhone6

我在沒有崩潰的情況下收到此日志消息(我假設每個音頻幀有數百條)

2019-10-11 09:31:59.138013+0200 WyntonHost[537:96101] 55: EXCEPTION (-1): ""
2019-10-11 09:31:59.161233+0200 WyntonHost[537:96101] 55: EXCEPTION (-1): ""

知道此日志消息來自哪里嗎?

我也遇到了這樣的問題,然后我已經解決了。

您需要更改 EZAudioFloatConverter.m 中的代碼

- (void)convertDataFromAudioBufferList:(AudioBufferList *)audioBufferList
                    withNumberOfFrames:(UInt32)frames
                        toFloatBuffers:(float **)buffers
                    packetDescriptions:(AudioStreamPacketDescription *)packetDescriptions

在這種方法中,您應該進行如下更改:

OSStatus status = AudioConverterFillComplexBuffer(self.info->converterRef,
                                                  EZAudioFloatConverterCallback,
                                                  audioBufferList,
                                                  &frames,
                                                  self.info->floatAudioBufferList,
                                                  packetDescriptions ? packetDescriptions : self.info->packetDescriptions);
if (status > 0 ) {
    AudioConverterReset(self.info->converterRef);
}

我已經改變了它,它對我來說運行良好。

參考鏈接:

https://github.com/syedhali/EZAudio/issues/379

https://github.com/AudioKit/AudioKit/issues/1873

您還可以下載我的代碼已更改的代碼:

https://github.com/liunianhuaguoyanxi/EZAudio

我希望這可以幫助你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM