fix(sdr): bound decoder work and stabilize FM playback

Keep USB reads in a bounded ordered pipeline, acknowledge and cap decoder
work, terminate stopped workers, and buffer short playback jitter. Throttle
display telemetry and compute spectra only while seeking.

Preserve PR #1174's wrapped seeking and fresh-spectrum tagging. Add opt-in
bounded timing diagnostics and decoder/playback lifecycle regressions.

Co-authored-by: Aditya <[email protected]>
This commit is contained in:
Mazeyar Moeini FeizabadiandAditya committed 2026-10-16 18:37:15 +02:00
1 parent 537e99dfa4
commit 240f7ae3da
10 files changed
+2305 -75

No files matched your search

+20
View File
@@ -41,3 +41,23 @@ test('directional FM seek chooses the nearest rounded station in-band', () => {
null,
);
});
test('directional FM seek passes over the skipped channel to the next station', () => {
const sampleRate = 2_048_000;
const bins = new Float32Array(2_048).fill(-80);
// Carriers at 98.8 and 99.1 MHz in a frame centred on 98.5 MHz. A carrier
// 100 kHz away would sit inside the peak test's 150 kHz comparison window.
for (const offset of [300_000, 600_000]) {
const index = offset / (sampleRate / bins.length) + bins.length / 2;
for (let bin = index - 5; bin <= index + 5; bin += 1) bins[bin] = -10;
}
const seek = (skipFrequency) =>
findDirectionalFmPeak(bins, 98_500_000, sampleRate, 1, 98_500_000, {
skipFrequency,
})?.frequency;
assert.equal(seek(undefined), 98_800_000);
assert.equal(seek(98_800_000), 99_100_000);
// The skip covers channels up to and including 75 kHz away.
assert.equal(seek(98_725_000), 99_100_000);
assert.equal(seek(98_724_999), 98_800_000);
});