From a8aed6b344a5e190d7da856e09f9ac75c0f8536f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 3 Jun 2021 21:02:27 -0500 Subject: [PATCH] Avoid spurious audio data loss warning on connection start --- src/RtpAudioQueue.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/RtpAudioQueue.c b/src/RtpAudioQueue.c index d52d8d9..2b1dc9a 100644 --- a/src/RtpAudioQueue.c +++ b/src/RtpAudioQueue.c @@ -167,6 +167,15 @@ static PRTPA_FEC_BLOCK getFecBlockForRtpPacket(PRTP_AUDIO_QUEUE queue, PRTP_PACK return NULL; } + // Synchronize the nextRtpSequenceNumber and oldestRtpBaseSequenceNumber values + // when the connection begins. Start on the next FEC block boundary, so we can + // be sure we aren't starting in the middle (which will lead to a spurious audio + // data block recovery warning on connection start if we miss more than 2 packets). + if (queue->nextRtpSequenceNumber == UINT16_MAX && queue->oldestRtpBaseSequenceNumber == 0) { + queue->nextRtpSequenceNumber = queue->oldestRtpBaseSequenceNumber = fecBlockBaseSeqNum + RTPA_DATA_SHARDS; + return NULL; + } + // Drop packets from FEC blocks that have already been completed if (isBefore16(fecBlockBaseSeqNum, queue->oldestRtpBaseSequenceNumber)) { return NULL; @@ -390,13 +399,6 @@ int RtpaAddPacket(PRTP_AUDIO_QUEUE queue, PRTP_PACKET packet, uint16_t length) { return 0; } - // Synchronize the nextRtpSequenceNumber and oldestRtpBaseSequenceNumber values - // when the connection begins. We want to always start on FEC block boundaries. - if (queue->nextRtpSequenceNumber == UINT16_MAX && queue->oldestRtpBaseSequenceNumber == 0) { - queue->nextRtpSequenceNumber = queue->oldestRtpBaseSequenceNumber = fecBlock->fecHeader.baseSequenceNumber; - validateFecBlockState(queue); - } - if (packet->packetType == 97) { uint16_t pos = packet->sequenceNumber - fecBlock->fecHeader.baseSequenceNumber;