fix: only downgrade the short pre-event warning when the queue was never trimmed

get_event_start_packet_it() logged "Hit end of packetqueue before
satisfying pre_event_count" at Debug when packet->image_index was below
pre_event_count, assuming that meant zmc had just started. image_index
comes from shared_data->image_count, which is not reset when a capture
reconnect runs Monitor::Pause() and clears the packetqueue. An event
opened on the first frames after a reconnect therefore logged a Warning
for a short pre-event buffer that cannot be avoided.

Record the queue_index of the first packet queued since the last clear()
and log at Debug when the walk back stops on that packet, i.e. nothing
has been trimmed since startup or the reconnect. A Warning now means
packets really were removed below the pre-event count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Isaac ConnorandClaude Opus 5.5 committed 2026-09-29 19:07:41 -04:00
1 parent 01f0bc73ac
commit 2dcc2f3314
2 files changed
+7 -3

No files matched your search

+6 -3
View File
@@ -41,7 +41,8 @@ PacketQueue::PacketQueue():
max_keyframe_interval_(0),
frames_since_last_keyframe_(0),
clear_packets_pending_(false),
next_queue_index_(0)
next_queue_index_(0),
first_queue_index_(0)
{
}
@@ -465,6 +466,7 @@ void PacketQueue::clear() {
packet_counts.reset();
max_stream_id = -1;
max_keyframe_interval_ = 0;
first_queue_index_ = next_queue_index_;
Debug(1, "Packetqueue is clear, notifying");
condition.notify_all();
@@ -678,8 +680,9 @@ packetqueue_iterator *PacketQueue::get_event_start_packet_it(
}
if (pre_event_count) {
if (packet->image_index < (int)pre_event_count) {
// probably just starting up
if (packet->queue_index == first_queue_index_) {
// Nothing has been trimmed since startup or the last clear() (e.g. a
// capture reconnect), so the queue never held enough packets.
Debug(1, "Hit end of packetqueue before satisfying pre_event_count. Needed %d more video frames", pre_event_count);
} else {
Warning("Hit end of packetqueue before satisfying pre_event_count. Needed %d more video frames", pre_event_count);
+1
View File
@@ -55,6 +55,7 @@ class PacketQueue {
int frames_since_last_keyframe_;
std::atomic<bool> clear_packets_pending_;
uint64_t next_queue_index_;
uint64_t first_queue_index_; // queue_index of the first packet queued since the last clear()
public:
PacketQueue();