From 425e9f0484a0442ccdc07a30a77f7c37a4fb59b1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 11 Aug 2015 22:49:49 -0700 Subject: [PATCH] Fix an RTP queue bug that can cause extended packet delays when the last packet ages out of the queue --- limelight-common/RtpReorderQueue.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/limelight-common/RtpReorderQueue.c b/limelight-common/RtpReorderQueue.c index 0f6a5d2..b791048 100644 --- a/limelight-common/RtpReorderQueue.c +++ b/limelight-common/RtpReorderQueue.c @@ -202,6 +202,13 @@ int RtpqAddPacket(PRTP_REORDER_QUEUE queue, PRTP_PACKET packet, PRTP_QUEUE_ENTRY // and get the lowest element lowestEntry = validateQueueConstraints(queue); + // If the queue is now empty after validating queue constraints, + // this packet can be returned immediately + if (lowestEntry == NULL && queue->queueHead == NULL) { + queue->nextRtpSequenceNumber = packet->sequenceNumber + 1; + return RTPQ_RET_HANDLE_IMMEDIATELY; + } + // Queue has data inside, so we need to see where this packet fits if (packet->sequenceNumber == queue->nextRtpSequenceNumber) { // It fits in a hole where we need a packet, now we have some ready