fix: add jitter buffer, sequence tracking, and mic error reporting
Add a jitter buffer in OnAudioStream that collects incoming audio packets, sorts by sequence number, and releases them in order after a small initial delay (3 packets, ~30ms). This prevents out-of-order playback from network jitter and reordered UDP packets. Add a Sequence field to AudioPacket so the jitter buffer can reorder by sequence number. PLC frames generated by dispatchPLC now also carry the correct sequence number so they integrate with the jitter buffer. Add microphone capture error reporting: when CaptureSamples returns fewer bytes than expected, report the failure to the user via a callback. The error is reported once when the failure starts and again when the mic recovers. Wire this up in client.go to display status messages.
This commit is contained in:
committed by
Brandon McGinty
parent
9dd0137975
commit
0858cd3542
@@ -53,6 +53,13 @@ func (b *Barnard) connect(reconnect bool) bool {
|
||||
b.Stream = stream
|
||||
b.Stream.AttachStream(b.Client)
|
||||
b.Stream.SetNoiseProcessor(b.NoiseSuppressor)
|
||||
b.Stream.SetErrorFunc(func(err error) {
|
||||
if err != nil {
|
||||
b.AddOutputLine(fmt.Sprintf("Microphone: %s", err.Error()))
|
||||
} else {
|
||||
b.AddOutputLine("Microphone: recovered")
|
||||
}
|
||||
})
|
||||
|
||||
// Initialize stereo encoder for file playback
|
||||
b.Client.AudioEncoderStereo = opus.NewStereoEncoder()
|
||||
|
||||
Reference in New Issue
Block a user