From a9be72afba6d85119e90296628bd61418ec37b17 Mon Sep 17 00:00:00 2001 From: Nonoo Date: Thu, 29 Oct 2020 22:30:42 +0100 Subject: [PATCH] Fixes for the TX seqbuf --- txseqbuf.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/txseqbuf.go b/txseqbuf.go index 1f536b2..f948f6e 100644 --- a/txseqbuf.go +++ b/txseqbuf.go @@ -2,6 +2,9 @@ package main import "time" +// This value is sent to the transceiver and - according to my observations - it will use +// this is it's RX buf length. Note that if it is set to larger than 500-600ms then audio TX +// won't work (small radio memory?) const txSeqBufLength = 300 * time.Millisecond type txSeqBufStruct struct { @@ -18,7 +21,9 @@ func (s *txSeqBufStruct) add(seq seqNum, p []byte) { } func (s *txSeqBufStruct) purgeOldEntries() { - for len(s.entries) > 0 && time.Since(s.entries[0].addedAt) > txSeqBufLength*2 { + // We keep much more entries than the specified length of the TX seqbuf, so we can serve + // any requests coming from the server. + for len(s.entries) > 0 && time.Since(s.entries[0].addedAt) > txSeqBufLength*10 { s.entries = s.entries[1:] } } @@ -31,7 +36,8 @@ func (s *txSeqBufStruct) get(seq seqNum) (d []byte) { // Searching from backwards, as we expect most queries for latest entries. for i := len(s.entries) - 1; i >= 0; i-- { if s.entries[i].seq == seq { - d = s.entries[i].data + d := make([]byte, len(s.entries[i].data)) + copy(d, s.entries[i].data) break } }