From 02a3fd565ee71c235c2e09d7c241858b35646300 Mon Sep 17 00:00:00 2001 From: Denny Ma Date: Mon, 16 Mar 2026 16:32:55 +1100 Subject: [PATCH] fix(dab): prevent cached_output overwrite by freq-correction-only packets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MetaProcessor.process() was replacing cached_output on every call with whatever fields happened to be in the current EtiDecoder packet. Most packets only contain timestamp + coarse/fine_frequency_shift — after filtering those out, the replacement left cached_output as {"mode":"DAB"}, wiping out the previously cached programmes/ensemble data. This caused the DAB programme list to stop loading in browsers ~1-2 minutes after initial connect (when the first freq-correction packet arrived). Fix: switch from assignment to dict.update(), merging only stable fields (programmes, ensemble_label, etc.). Freq-correction-only packets produce an empty stable set and no longer touch the cache. Paired with the getCachedMeta()/setMetaWriter() injection from the PR #421 port, this ensures the programme list is reliably available to all clients. Co-Authored-By: Claude Sonnet 4.6 --- csdr/chain/dablin.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/csdr/chain/dablin.py b/csdr/chain/dablin.py index f506580c..390a3f5c 100644 --- a/csdr/chain/dablin.py +++ b/csdr/chain/dablin.py @@ -44,10 +44,12 @@ class MetaProcessor(PickleModule): if not result: return result["mode"] = "DAB" - # Keep a snapshot of stable fields so late-connecting clients can get them - # immediately via setMetaWriter() injection. Exclude timestamp — it changes - # every second and the injected copy would be stale anyway. - self.cached_output = {k: v for k, v in result.items() if k != "timestamp"} + # Merge only stable fields (programmes, ensemble_label, etc.) into the cache. + # Do NOT replace the whole dict — freq-correction-only packets have no + # stable fields and would wipe out previously cached programme data. + stable = {k: v for k, v in result.items() if k not in ("timestamp", "mode")} + if stable: + self.cached_output.update(stable) return result def _nudgeShift(self, amount):