fix: leave the signal flag to the decoder when it checks SignalCheckPoints

Capture set shared_data->signal to true for every packet while the
decoder set it to CheckSignal() for every decoded frame. With
SignalCheckPoints on and a camera showing its lost-signal picture,
Analyse sometimes read Capture's true between two decoded frames, so the
signal flipped back for one frame: the event was closed for signal loss
and a zero-frame "Signal: Reacquired" event opened, about once a minute.

Capture now writes true only when no decoder measures the signal: no
SignalCheckPoints, Decoding=None, or on-demand decoding with no viewer.
It still writes true for the first packet after connect(), as before, so
Analyse doesn't see a signal loss before the first decoded frame and the
first event keeps its cause. The capture-failure path still writes false.

fixes #5235

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nic BoetandClaude Opus 5.5 committed 2026-10-12 11:15:52 -05:00
1 parent c3d2e542bc
commit 68aa214ff7
4 files changed
+77 -2

No files matched your search

+23 -2
View File
@@ -289,6 +289,7 @@ Monitor::Monitor() :
first_alarm_count(0),
last_alarm_count(0),
last_signal(false),
assume_signal_on_next_packet(false),
buffer_count(0),
state(IDLE),
last_motion_score(0),
@@ -1131,6 +1132,7 @@ bool Monitor::connect() {
shared_data->capturing = capturing;
shared_data->recording = recording;
shared_data->signal = false;
assume_signal_on_next_packet = true;
shared_data->capture_fps = 0.0;
shared_data->analysis_fps = 0.0;
shared_data->latitude = latitude;
@@ -1930,6 +1932,20 @@ bool Monitor::CheckSignal(const Image *image) {
return false;
} // end bool Monitor::CheckSignal(const Image *image)
bool Monitor::DecoderChecksSignal(DecodingOption decoding, int signal_check_points, bool has_viewers) {
if (signal_check_points <= 0) return false;
switch (decoding) {
case DECODING_ALWAYS:
case DECODING_KEYFRAMES:
case DECODING_KEYFRAMESONDEMAND:
return true;
case DECODING_ONDEMAND:
return has_viewers;
default:
return false;
}
}
void Monitor::CheckAction() {
if (shared_data->action) {
@@ -3093,8 +3109,13 @@ int Monitor::Capture() {
// Don't want to do analysis on it, but we won't due to signal
return -1;
} else if (captureResult > 0) {
shared_data->signal = true; // Assume if getting packets that we are getting something useful. CheckSignalPoints can correct this later.
// If we captured, let's assume signal, Decode will detect further
// Getting packets: assume signal unless the decoder measures it
// (SignalCheckPoints). Writing true here as well made a lost-signal
// picture flip back to "signal" between decoded frames.
if (assume_signal_on_next_packet or !DecoderChecksSignal(decoding, signal_check_points, hasViewers())) {
shared_data->signal = true;
assume_signal_on_next_packet = false;
}
if (decoding == DECODING_NONE) {
shared_data->last_write_index = index;
shared_data->last_write_time = std::chrono::system_clock::to_time_t(packet->timestamp);