From b16eb510d07dd0d738d133bd40e50c745f353f06 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 4 Jun 2021 15:03:08 -0400 Subject: [PATCH] More debugging around clearQueue. return early if deleting --- src/zm_packetqueue.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index d52c188d3..9662e4958 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -178,6 +178,8 @@ void PacketQueue::clearPackets(const std::shared_ptr &add_packet) { // // So start at the beginning, counting video packets until the next keyframe. // Then if deleting those packets doesn't break 1 and 2, then go ahead and delete them. + if (deleting) return; + if (keep_keyframes and ! ( add_packet->packet.stream_index == video_stream_id and @@ -331,10 +333,19 @@ void PacketQueue::clear() { // Someone might have this packet, but not for very long and since we have locked the queue they won't be able to get another one ZMLockedPacket *lp = new ZMLockedPacket(packet); lp->lock(); + Debug(1, + "Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu", + packet->packet.stream_index, + packet->image_index, + packet->keyframe, + packet_counts[video_stream_id], + pre_event_video_packet_count, + pktQueue.size()); pktQueue.pop_front(); delete lp; //delete packet; } + Debug(1, "Packetqueue is clear, deleting iterators"); for ( std::list::iterator iterators_it = iterators.begin(); @@ -349,6 +360,7 @@ void PacketQueue::clear() { packet_counts = nullptr; max_stream_id = -1; + Debug(1, "Packetqueue is clear, notifying"); condition.notify_all(); }