From 9580c1ada87f8f8aa0b7a0a56b42d5766c70046b Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Thu, 19 Mar 2026 13:25:07 +0100 Subject: [PATCH] Prepare gpudemod batch runner for stream-backed slots --- internal/demod/gpudemod/batch_runner.go | 40 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/internal/demod/gpudemod/batch_runner.go b/internal/demod/gpudemod/batch_runner.go index 084d548..2afc9d0 100644 --- a/internal/demod/gpudemod/batch_runner.go +++ b/internal/demod/gpudemod/batch_runner.go @@ -1,7 +1,15 @@ package gpudemod +type batchSlot struct { + job ExtractJob + out []complex64 + rate int + active bool +} + type BatchRunner struct { - eng *Engine + eng *Engine + slots []batchSlot } func NewBatchRunner(maxSamples int, sampleRate int) (*BatchRunner, error) { @@ -18,11 +26,39 @@ func (r *BatchRunner) Close() { } r.eng.Close() r.eng = nil + r.slots = nil +} + +func (r *BatchRunner) prepare(jobs []ExtractJob) { + if cap(r.slots) < len(jobs) { + r.slots = make([]batchSlot, len(jobs)) + } else { + r.slots = r.slots[:len(jobs)] + } + for i, job := range jobs { + r.slots[i] = batchSlot{job: job, active: true} + } } func (r *BatchRunner) ShiftFilterDecimateBatch(iq []complex64, jobs []ExtractJob) ([][]complex64, []int, error) { if r == nil || r.eng == nil { return nil, nil, ErrUnavailable } - return r.eng.ShiftFilterDecimateBatch(iq, jobs) + r.prepare(jobs) + outs := make([][]complex64, len(jobs)) + rates := make([]int, len(jobs)) + for i := range r.slots { + if !r.slots[i].active { + continue + } + out, rate, err := r.eng.ShiftFilterDecimate(iq, r.slots[i].job.OffsetHz, r.slots[i].job.BW, r.slots[i].job.OutRate) + if err != nil { + return nil, nil, err + } + r.slots[i].out = out + r.slots[i].rate = rate + outs[i] = out + rates[i] = rate + } + return outs, rates, nil }