From 1ab9e4c853d9dd8b755b713bc2e90808f6e7bb8b Mon Sep 17 00:00:00 2001 From: Nonoo Date: Thu, 29 Oct 2020 15:55:21 +0100 Subject: [PATCH] Send the length of the TX buf to the server --- controlstream.go | 6 ++++-- txseqbuf.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controlstream.go b/controlstream.go index 42931cc..5d4aaca 100644 --- a/controlstream.go +++ b/controlstream.go @@ -96,6 +96,8 @@ func (s *controlStream) sendPktAuth(magic byte) error { func (s *controlStream) sendRequestSerialAndAudio() error { log.Debug("requesting serial and audio stream") + txSeqBufLengthMs := uint16(txSeqBufLength.Milliseconds()) + p := []byte{0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID), byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID), @@ -114,8 +116,8 @@ func (s *controlStream) sendRequestSerialAndAudio() error { 0x01, 0x01, 0x04, 0x04, 0x00, 0x00, byte(audioSampleRate >> 8), byte(audioSampleRate & 0xff), 0x00, 0x00, byte(audioSampleRate >> 8), byte(audioSampleRate & 0xff), 0x00, 0x00, byte(serialStreamPort >> 8), byte(serialStreamPort & 0xff), - 0x00, 0x00, byte(audioStreamPort >> 8), byte(audioStreamPort & 0xff), 0x00, 0x00, 0x00, 0xa0, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + 0x00, 0x00, byte(audioStreamPort >> 8), byte(audioStreamPort & 0xff), 0x00, 0x00, + byte(txSeqBufLengthMs >> 8), byte(txSeqBufLengthMs & 0xff), 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} if err := s.common.pkt0.sendTrackedPacket(&s.common, p); err != nil { return err } diff --git a/txseqbuf.go b/txseqbuf.go index 31b146e..176e1aa 100644 --- a/txseqbuf.go +++ b/txseqbuf.go @@ -2,6 +2,8 @@ package main import "time" +const txSeqBufLength = 500 * time.Millisecond + type txSeqBufStruct struct { entries []seqBufEntry } @@ -16,7 +18,7 @@ func (s *txSeqBufStruct) add(seq seqNum, p []byte) { } func (s *txSeqBufStruct) purgeOldEntries() { - for len(s.entries) > 0 && time.Since(s.entries[0].addedAt) > time.Second { + for len(s.entries) > 0 && time.Since(s.entries[0].addedAt) > txSeqBufLength { s.entries = s.entries[1:] } }