Skip to content

Commit 1b36941

Browse files
Check for iterator pointing to first packet. This is a special case.
1 parent 42b74d8 commit 1b36941

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/zm_packetqueue.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,22 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
311311
}
312312

313313
int keyframe_interval_count = 1;
314+
int video_packets_to_delete = 0; // This is a count of how many packets we will delete so we know when to stop looking
314315

315316
ZMLockedPacket *lp = new ZMLockedPacket(zm_packet);
316317
if (!lp->trylock()) {
317318
Debug(4, "Failed getting lock on first packet");
318319
delete lp;
319320
return;
320321
} // end if first packet not locked
322+
323+
if (is_there_an_iterator_pointing_to_packet(zm_packet)) {
324+
Debug(3, "Found iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
325+
video_packets_to_delete, packet_counts[video_stream_id]-video_packets_to_delete, tail_count);
326+
delete lp;
327+
return;
328+
}
321329

322-
int video_packets_to_delete = 0; // This is a count of how many packets we will delete so we know when to stop looking
323330
++it;
324331
delete lp;
325332

@@ -335,7 +342,7 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
335342
delete lp;
336343

337344
if (is_there_an_iterator_pointing_to_packet(zm_packet)) {
338-
Debug(3, "Foudn iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
345+
Debug(3, "Found iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
339346
video_packets_to_delete, packet_counts[video_stream_id]-video_packets_to_delete, tail_count);
340347
break;
341348
}
@@ -595,6 +602,7 @@ packetqueue_iterator *PacketQueue::get_event_start_packet_it(
595602

596603
packetqueue_iterator *it = new packetqueue_iterator;
597604
iterators.push_back(it);
605+
Debug(4, "Have event start iterator %p", std::addressof(*it));
598606

599607
*it = snapshot_it;
600608
std::shared_ptr<ZMPacket> packet = *(*it);
@@ -714,6 +722,7 @@ bool PacketQueue::is_there_an_iterator_pointing_to_packet(const std::shared_ptr<
714722
) {
715723
packetqueue_iterator *iterator_it = *iterators_it;
716724
if (*iterator_it == pktQueue.end()) {
725+
Debug(4, "Checking iterator %p == end", std::addressof(*iterator_it));
717726
continue;
718727
}
719728
Debug(4, "Checking iterator %p == packet ? %d", std::addressof(*iterator_it), ( *(*iterator_it) == zm_packet ));

0 commit comments

Comments
 (0)