From 131c46f8c539b065feb397e2ee706cff1c81e4cc Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sat, 20 Jun 2026 11:16:52 -0500 Subject: cleanup phase 1: stale-comment refresh, zero behavior change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes/rewrites every comment that referenced the dead HTTP-streaming architecture so a reader of v1.0.0+ source isn't chasing a model that's been gone for several releases. No code paths changed; this is the safe pre-pass before Phase 2's actual deletions. Firmware (main/http_api.c): - s_last_painted_seq / s_last_post_us / X-Frame-Seq parse / stale- frame guard / Server-Timing emission / TCP_NODELAY setsockopt / max_open_sockets=4 — each block now leads with "(Legacy from the HTTP-streaming era; removed in Phase 2)" so the reader knows the block is doomed, not load-bearing. - /frame dim-mismatch comment narrowed: panel-native is always 800x480 BGR888, no Scrypted-side variation expected; Scrypted does the rotation+scale via sharp/mediaManager/ffmpeg cascade (snapshot) or ffmpeg -vf (stream). - "Single in-flight frame. Concurrent posts get 503" rewritten to reflect: decoder mutex now mostly serves to fence /frame snapshots against an active stream_server decode. Firmware (main/stream_server.c:136-142): - FIONREAD-skip rationale reduced from a 7-line paragraph to one sentence; the savings/tradeoff math now lives in the plan, not the per-line comment. Script (scrypted/scrypted-viewport.ts): - Top-of-file tuning constants block drops the "frame_interval_ms removed", "fps filter", "in-flight back-to-back startStream" rationale; one short line covers the model: "Stream rate is paced by camera + TCP backpressure; no app-level fps cap." - agentFor() rationale rewritten: this Agent is over-engineered for control-plane traffic (~1 POST/min steady state) — a legacy of when it backed per-frame /frame POSTs. Marked for Phase 2 retirement. - noDelay on Agent: clarified it's now a no-op safety for control plane (was load-bearing for live-stream pipelining). - snapshot fire-and-forget comment: replaced X-Frame-Seq-race rationale with the actual TCP-streaming truth (sharp/mediaManager/ ffmpeg cascade race against stream socket bring-up). - writeLatencies probe: rewrote the "keep-alive socket" comment (live stream uses raw net.Socket, not the http.Agent pool). - socketBackpressured: explicit "diagnostic only, never gates writes" comment added at declaration site. - skipLogger header: rewrote the inFlight/MAX_INFLIGHT/fps-filter rationale into a one-line description of what the log line actually emits today. - frameSeq map: now flagged as legacy of HTTP-streaming era, retired in Phase 2. --- main/stream_server.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'main/stream_server.c') diff --git a/main/stream_server.c b/main/stream_server.c index 10d1e1b..38769f0 100644 --- a/main/stream_server.c +++ b/main/stream_server.c @@ -133,13 +133,9 @@ static void handle_client(int fd, const char *peer) continue; } - // "Always paint the latest" — if the socket already has more - // bytes queued in the kernel receive buffer, at least one more - // header is on the way. The frame we just finished receiving - // is no longer the freshest possible; skip its decode+paint - // (saves ~6ms per skip) and loop straight to the next header. - // This trades some intermediate frames for lower - // glass-to-glass latency on the latest one. + // If the kernel already has another header queued, this frame + // is no longer the freshest; skip decode + paint, loop back to + // the head-of-queue header. int queued = 0; if (ioctl(fd, FIONREAD, &queued) == 0 && queued >= HEADER_BYTES) { jpeg_decoder_unlock(); -- cgit v1.2.3