mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Return the oldest packet instead of removing it upon RTP queue constraint violation
This commit is contained in:
parent
be78c36fa1
commit
a5b5ed8d2b
@ -134,7 +134,7 @@ static void removeEntry(PRTP_REORDER_QUEUE queue, PRTP_QUEUE_ENTRY entry) {
|
||||
}
|
||||
|
||||
static PRTP_QUEUE_ENTRY validateQueueConstraints(PRTP_REORDER_QUEUE queue) {
|
||||
int needsUpdate = 0;
|
||||
int dequeuePacket = 0;
|
||||
|
||||
// Empty queue is fine
|
||||
if (queue->queueHead == NULL) {
|
||||
@ -143,24 +143,19 @@ 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\n");
|
||||
removeEntry(queue, queue->oldestQueuedEntry);
|
||||
free(queue->oldestQueuedEntry->packet);
|
||||
needsUpdate = 1;
|
||||
Limelog("Returning RTP packet queued for too long\n");
|
||||
dequeuePacket = 1;
|
||||
}
|
||||
|
||||
// Check that the queue's size constraint is satisfied
|
||||
if (!needsUpdate && queue->queueSize == queue->maxSize) {
|
||||
Limelog("Discarding RTP packet after queue overgrowth\n");
|
||||
removeEntry(queue, queue->oldestQueuedEntry);
|
||||
free(queue->oldestQueuedEntry->packet);
|
||||
needsUpdate = 1;
|
||||
// Check that the queue's size constraint is satisfied. We subtract one
|
||||
// because this is validating that the queue will meet constraints _after_
|
||||
// the current packet is enqueued.
|
||||
if (!dequeuePacket && queue->queueSize == queue->maxSize - 1) {
|
||||
Limelog("Returning RTP packet after queue overgrowth\n");
|
||||
dequeuePacket = 1;
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
// Recalculate the oldest entry if needed
|
||||
updateOldestQueued(queue);
|
||||
|
||||
if (dequeuePacket) {
|
||||
// Return the lowest seq queued
|
||||
return getEntryByLowestSeq(queue);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user