EZAudio是一款很強(qiáng)大的波形繪制開源庫,
最近需求中IM聊天發(fā)送錄音有所涉及今阳,接入后確實(shí)感覺很厲害街佑,但是由于該庫開源很久了,作者沒怎么維護(hù)了屹徘,而iOS13+會(huì)必現(xiàn)crash走趋。經(jīng)過了分析研究,梳理出了解決方案:
具體如下:
當(dāng)遇見必現(xiàn) iOS13 Crash - Error: Failed to fill complex buffer in float converter ('insz')
解決方法:
手動(dòng)替換 EZAudioFloatConverter.m中的以下方法的實(shí)現(xiàn)
- (void)convertDataFromAudioBufferList:(AudioBufferList *)audioBufferList
withNumberOfFrames:(UInt32)frames
toFloatBuffers:(float **)buffers
packetDescriptions:(AudioStreamPacketDescription *)packetDescriptions
復(fù)制以下內(nèi)容替換其實(shí)現(xiàn)
OSStatus status = AudioConverterFillComplexBuffer(self.info->converterRef,
EZAudioFloatConverterCallback,
audioBufferList,
&frames,
self.info->floatAudioBufferList,
packetDescriptions ? packetDescriptions : self.info->packetDescriptions);
if (status > 0 ) {
AudioConverterReset(self.info->converterRef);
}
如想詳細(xì)了解問題分析緣由以及解決方案的梳理噪伊,亦可查看我Stack Overflow的回答:
https://stackoverflow.com/questions/58336413/ios13-crash-error-failed-to-fill-complex-buffer-in-float-converter-insz/61721282#61721282
該庫的聲波圖繪制確實(shí)還不錯(cuò)簿煌,但最后建議錄音最好用原生的AVAudioRecorder來錄制,別用它封裝的Recorder來錄制酥宴。