fixed possible crash in micHandler

This commit is contained in:
TrueZhuanjia committed 2025-09-15 11:37:50 +08:00
1 parent b950882846
commit 464492529e
1 file changed
+3 -2
+3 -2
View File
@@ -195,8 +195,9 @@ public class MicHandler: NSObject {
guard let enc = self.opusEncoder else {return} guard let enc = self.opusEncoder else {return}
let outBytes = opus_encode(enc, chunk, 960, &packet, Int32(packet.count)) let outBytes = opus_encode(enc, chunk, 960, &packet, Int32(packet.count))
sendMicrophoneData(packet, outBytes) sendMicrophoneData(packet, outBytes)
if pcm16Buffer.count >= 960 { let removeCount = min(960, pcm16Buffer.count)
pcm16Buffer.removeFirst(960) if removeCount > 0 {
pcm16Buffer.removeFirst(removeCount)
} }
} }
} }