use get_packet_and_increment_it instead of the two step to improve locking

This commit is contained in:
Isaac Connor 2021-09-08 18:35:01 -04:00
parent c5b097af0a
commit a44bbf8e34
1 changed files with 2 additions and 4 deletions

View File

@ -1723,7 +1723,7 @@ bool Monitor::Analyse() {
// if have event, send frames until we find a video packet, at which point do analysis. Adaptive skip should only affect which frames we do analysis on. // if have event, send frames until we find a video packet, at which point do analysis. Adaptive skip should only affect which frames we do analysis on.
// get_analysis_packet will lock the packet and may wait if analysis_it is at the end // get_analysis_packet will lock the packet and may wait if analysis_it is at the end
ZMLockedPacket *packet_lock = packetqueue.get_packet(analysis_it); ZMLockedPacket *packet_lock = packetqueue.get_packet_and_increment_it(analysis_it);
if (!packet_lock) return false; if (!packet_lock) return false;
std::shared_ptr<ZMPacket> snap = packet_lock->packet_; std::shared_ptr<ZMPacket> snap = packet_lock->packet_;
@ -1731,13 +1731,11 @@ bool Monitor::Analyse() {
if (snap->score != -1) { if (snap->score != -1) {
Error("skipping because score was %d", snap->score); Error("skipping because score was %d", snap->score);
packetqueue.unlock(packet_lock); packetqueue.unlock(packet_lock);
packetqueue.increment_it(analysis_it);
return false; return false;
} }
// Store the it that points to our snap we will need it later // Store the it that points to our snap we will need it later
packetqueue_iterator snap_it = *analysis_it; packetqueue_iterator snap_it = std::prev(*analysis_it);
packetqueue.increment_it(analysis_it);
// signal is set by capture // signal is set by capture
bool signal = shared_data->signal; bool signal = shared_data->signal;