From 5367ab3e68f06ef0485a9f042267b322640eb1f0 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 12 Mar 2020 20:43:27 +0100 Subject: [PATCH] FIx --- controller/net/JitterBuffer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/controller/net/JitterBuffer.cpp b/controller/net/JitterBuffer.cpp index 679804b..6e3f9a2 100755 --- a/controller/net/JitterBuffer.cpp +++ b/controller/net/JitterBuffer.cpp @@ -91,18 +91,18 @@ void JitterBuffer::PutInternal(jitter_packet_t &pkt, bool overwriteExisting) return; } - if (overwriteExisting) + auto existing = std::find_if(slots.begin(), slots.end(), [timestamp = pkt.timestamp](const jitter_packet_t &slot) -> bool { + return slot.timestamp == timestamp && !slot.buffer.IsEmpty(); + }); + if (existing != slots.end()) { - for (auto &slot : slots) + if (overwriteExisting) { - if (slot.timestamp == pkt.timestamp && !slot.buffer.IsEmpty()) - { - slot.buffer.CopyFromOtherBuffer(pkt.buffer, pkt.size); - slot.size = pkt.size; - slot.isEC = pkt.isEC; - return; - } + existing->buffer.CopyFromOtherBuffer(pkt.buffer, pkt.size); + existing->size = pkt.size; + existing->isEC = pkt.isEC; } + return; } gotSinceReset++;