EZAudio iOS13+ Crash解决方案

EZAudio是一款很强大的波形绘制开源库,
最近需求中IM聊天发送录音有所涉及,接入后确实感觉很厉害,但是由于该库开源很久了,作者没怎么维护了,而iOS13+会必现crash。经过了分析研究,梳理出了解决方案:
具体如下:
当遇见必现 iOS13 Crash - Error: Failed to fill complex buffer in float converter ('insz')

解决方法:
手动替换 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);
}

如想详细了解问题分析缘由以及解决方案的梳理,亦可查看我Stack Overflow的回答:
https://stackoverflow.com/questions/58336413/ios13-crash-error-failed-to-fill-complex-buffer-in-float-converter-insz/61721282#61721282

该库的声波图绘制确实还不错,但最后建议录音最好用原生的AVAudioRecorder来录制,别用它封装的Recorder来录制。

你可能感兴趣的:(EZAudio iOS13+ Crash解决方案)