When camera->Capture() failed, Monitor::Capture() painted a frame of the
signal check colour into the shared image ring and moved
last_write_index, while the decoder thread could still be writing the
same ring. Capture picked its slot from image_count and the decoder from
last_write_index + 1, so the two could write one slot, giving a viewer a
torn frame, or move last_write_index backwards.
With a decoder thread running, the failure path now only sets
signal = false and leaves the ring to the decoder. Viewers keep its last
frame until the reconnect. That frame was short-lived anyway: zmc closes
the monitor and reconnects straight after the failure, and connect()
clears the ring. The decoder still runs CheckSignal on every decoded
frame, so a capture card's no-signal colour is still detected. With
decoding off nothing else writes the ring, so the signal colour frame is
still written there.
The test drives Capture() with a camera that always fails: with a
decoder the ring, last_write_index and image_count are unchanged;
without one the frame goes into image_count's slot as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>