diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 6c8860175..6fc0ccd07 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -731,12 +731,12 @@ void Event::Run() { // The idea is to process the queue no matter what so that all packets get processed. // We only break if the queue is empty while (!terminate_ and !zm_terminate) { - ZMPacketLock locked_packet = packetqueue->get_packet_no_wait(packetqueue_it); - std::shared_ptr packet = locked_packet.packet_; + ZMPacketLock packet_lock = packetqueue->get_packet_no_wait(packetqueue_it); + std::shared_ptr packet = packet_lock.packet_; if (packet) { if (!packet->decoded) { Debug(1, "Not decoded"); - packet->unlock(); + packet_lock.unlock(); // Stay behind decoder Microseconds sleep_for = Microseconds(ZM_SAMPLE_RATE); Debug(4, "Sleeping for %" PRId64 "us", int64(sleep_for.count())); @@ -762,8 +762,6 @@ void Event::Run() { packet->analysis_image = nullptr; } } // end if packet->image - Debug(1, "Deleting packet lock"); - packet->unlock(); // Important not to increment it until after we are done with the packet because clearPackets checks for iterators pointing to it. packetqueue->increment_it(packetqueue_it); } else {