Send the length of the TX buf to the server

This commit is contained in:
Nonoo 2020-10-29 15:55:21 +01:00
parent eaa9eaa4b4
commit 1ab9e4c853
2 changed files with 7 additions and 3 deletions

View file

@ -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
}

View file

@ -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:]
}
}