Return early if packetqueue is empty instead of getting the lock. Return early in clear() if we are not initialised
This commit is contained in:
parent
28d813b95a
commit
9f8c8a2664
|
@ -179,6 +179,7 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
|
||||||
// So start at the beginning, counting video packets until the next keyframe.
|
// 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.
|
// Then if deleting those packets doesn't break 1 and 2, then go ahead and delete them.
|
||||||
if (deleting) return;
|
if (deleting) return;
|
||||||
|
if (!pktQueue.size()) return;
|
||||||
|
|
||||||
if (keep_keyframes and ! (
|
if (keep_keyframes and ! (
|
||||||
add_packet->packet.stream_index == video_stream_id
|
add_packet->packet.stream_index == video_stream_id
|
||||||
|
@ -197,7 +198,6 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> lck(mutex);
|
std::unique_lock<std::mutex> lck(mutex);
|
||||||
if (!pktQueue.size()) return;
|
|
||||||
|
|
||||||
// If analysis_it isn't at the end, we need to keep that many additional packets
|
// If analysis_it isn't at the end, we need to keep that many additional packets
|
||||||
int tail_count = 0;
|
int tail_count = 0;
|
||||||
|
@ -325,6 +325,8 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
|
||||||
void PacketQueue::clear() {
|
void PacketQueue::clear() {
|
||||||
deleting = true;
|
deleting = true;
|
||||||
condition.notify_all();
|
condition.notify_all();
|
||||||
|
if (!packet_counts) // special case, not initialised
|
||||||
|
return;
|
||||||
Debug(1, "Clearing packetqueue");
|
Debug(1, "Clearing packetqueue");
|
||||||
std::unique_lock<std::mutex> lck(mutex);
|
std::unique_lock<std::mutex> lck(mutex);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue