From 0b6727e92d3f60230f3aa01fe52fb27cae1bcc15 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 28 May 2015 09:06:51 -0500 Subject: [PATCH] Fix some RTP queue bugs --- limelight-common/RtpReorderQueue.c | 7 ++++--- limelight-common/VideoStream.c | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/limelight-common/RtpReorderQueue.c b/limelight-common/RtpReorderQueue.c index 393e3c2..0f6a5d2 100644 --- a/limelight-common/RtpReorderQueue.c +++ b/limelight-common/RtpReorderQueue.c @@ -15,7 +15,7 @@ void RtpqCleanupQueue(PRTP_REORDER_QUEUE queue) { while (queue->queueHead != NULL) { PRTP_QUEUE_ENTRY entry = queue->queueHead; queue->queueHead = entry->next; - free(entry); + free(entry->packet); } } @@ -47,6 +47,7 @@ static int queuePacket(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY newEntry, int if (queue->oldestQueuedTimeMs == UINT64_MAX) { queue->oldestQueuedTimeMs = newEntry->queueTimeMs; + queue->oldestQueuedEntry = newEntry; } if (queue->queueHead == NULL) { @@ -144,7 +145,7 @@ static PRTP_QUEUE_ENTRY validateQueueConstraints(PRTP_REORDER_QUEUE queue) { // Check that the queue's time constraint is satisfied if (PltGetMillis() - queue->oldestQueuedTimeMs > queue->maxQueueTimeMs) { - Limelog("Discarding RTP packet queued for too long"); + Limelog("Discarding RTP packet queued for too long\n"); removeEntry(queue, queue->oldestQueuedEntry); free(queue->oldestQueuedEntry->packet); needsUpdate = 1; @@ -152,7 +153,7 @@ static PRTP_QUEUE_ENTRY validateQueueConstraints(PRTP_REORDER_QUEUE queue) { // Check that the queue's size constraint is satisfied if (!needsUpdate && queue->queueSize == queue->maxSize) { - Limelog("Discarding RTP packet after queue overgrowth"); + Limelog("Discarding RTP packet after queue overgrowth\n"); removeEntry(queue, queue->oldestQueuedEntry); free(queue->oldestQueuedEntry->packet); needsUpdate = 1; diff --git a/limelight-common/VideoStream.c b/limelight-common/VideoStream.c index f13241f..76cf925 100644 --- a/limelight-common/VideoStream.c +++ b/limelight-common/VideoStream.c @@ -113,6 +113,10 @@ static void ReceiveThreadProc(void* context) { free(buffer); } } + else if (queueStatus == RTPQ_RET_QUEUED_NOTHING_READY) { + // The queue owns the buffer + buffer = NULL; + } } if (buffer != NULL) {