get rid of O(n) ops on hot audio packet path

This commit is contained in:
Nick Payne
2025-07-10 20:43:17 +01:00
parent 1b537eb395
commit 4bc36019c2
2 changed files with 38 additions and 36 deletions
+3 -3
View File
@@ -74,7 +74,7 @@ public class AudioRecorder {
Logger.info("Audio device started successfully")
}
// FIXME: note to self, what about installTap? Would require audio engine and a node?
// Note to self, what about installTap? Would require audio engine and a node?
// No; AudioEngine.installTap() can only fire as often as 100ms. too slow for us
private func setupAndStartIOProc() {
Logger.debug("Creating IO proc")
@@ -127,8 +127,8 @@ public class AudioRecorder {
func stopRecording() {
// Send any remaining buffered audio, applying conversion if needed
if let finalPacket = audioBuffer?.flushRemaining() {
let processedPacket = converter?.transform(finalPacket) ?? finalPacket
audioBuffer?.processChunks().forEach { packet in
let processedPacket = converter?.transform(packet) ?? packet
outputHandler.handleAudioPacket(processedPacket)
}