Check for iterator pointing to first packet. This is a special case.

pull/4202/head
Isaac Connor 2024-07-29 16:11:31 -04:00
parent 0e87a4e982
commit cfdfe8344a
1 changed files with 13 additions and 4 deletions

View File

@ -284,6 +284,8 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
return;
}
int keyframe_interval_count = 1;
int video_packets_to_delete = 0; // This is a count of how many packets we will delete so we know when to stop looking
ZMLockedPacket *lp = new ZMLockedPacket(zm_packet);
if (!lp->trylock()) {
@ -291,9 +293,14 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
delete lp;
return;
} // end if first packet not locked
int keyframe_interval_count = 1;
int video_packets_to_delete = 0; // This is a count of how many packets we will delete so we know when to stop looking
if (is_there_an_iterator_pointing_to_packet(zm_packet)) {
Debug(3, "Found iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
video_packets_to_delete, packet_counts[video_stream_id]-video_packets_to_delete, tail_count);
delete lp;
return;
}
++it;
delete lp;
@ -309,7 +316,7 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
delete lp;
if (is_there_an_iterator_pointing_to_packet(zm_packet)) {
Debug(3, "Foudn iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
Debug(3, "Found iterator Counted %d video packets. Which would leave %d in packetqueue tail count is %d",
video_packets_to_delete, packet_counts[video_stream_id]-video_packets_to_delete, tail_count);
break;
}
@ -567,6 +574,7 @@ packetqueue_iterator *PacketQueue::get_event_start_packet_it(
packetqueue_iterator *it = new packetqueue_iterator;
iterators.push_back(it);
Debug(4, "Have event start iterator %p", std::addressof(*it));
*it = snapshot_it;
std::shared_ptr<ZMPacket> packet = *(*it);
@ -685,6 +693,7 @@ bool PacketQueue::is_there_an_iterator_pointing_to_packet(const std::shared_ptr<
) {
packetqueue_iterator *iterator_it = *iterators_it;
if (*iterator_it == pktQueue.end()) {
Debug(4, "Checking iterator %p == end", std::addressof(*iterator_it));
continue;
}
Debug(4, "Checking iterator %p == packet ? %d", std::addressof(*iterator_it), ( *(*iterator_it) == zm_packet ));