#2672 Polyphase channelizer enhancements to address buffer sizing and management

#2672 Bounds the polyphase buffer queue by sample duration instead of buffer count

The polyphase buffer processor queue was capped at 500 native buffers, which is only about 85 ms of samples for an RSP at 6 MSPS (about 1,000 samples per buffer) versus about 6.8 s for an RTL-SDR (32,768 samples per buffer).  Short processing stalls overflowed the queue and dropped buffers on RSP tuners.

- Dispatcher: adds a weight-bounded queue option (element weigher plus an  adjustable maximum queued weight).  Elements count toward the weight until  the listener has processed them.
- PolyphaseChannelManager: bounds the buffer queue at 1 second of samples and  updates the bound when the tuner sample rate changes.
- RspNativeBuffer: sampleCount() returned twice the complex sample count.  This  also corrects the tuner sample drop monitor and the spectral display buffer manager for RSP tuners.

Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
Denny Sheirer
2026-11-18 03:05:39 -05:00
committed by GitHub
parent f47479b8d4
commit f302d46be1
10 changed files with 337 additions and 70 deletions

View File

@@ -125,4 +125,60 @@ public class DispatcherTest
assertEquals(101, received.size());
}
/**
* Test: a weight-bounded queue drops elements that would exceed the maximum weight and keeps lighter ones.
*/
@Test
void weightBoundedQueueDropsElementsOverMaximumWeight() throws Exception
{
//Each element weighs its own value: 1 + 2 + 3 = 6 is queued, then 4 would exceed 6 and is dropped, then 0 fits
Dispatcher<Integer> dispatcher = new Dispatcher<>("test", 1, Integer::longValue, 6);
List<Integer> received = dispatchWhileBlocked(dispatcher, 4);
dispatcher.receive(0);
awaitSize(received, 5);
Thread.sleep(50);
dispatcher.stop();
assertEquals(List.of(0, 1, 2, 3, 0), received);
}
/**
* Test: an element heavier than the maximum weight is delivered when nothing else is queued.
*/
@Test
void weightBoundedQueueAcceptsHeavyElementWhenEmpty() throws Exception
{
Dispatcher<Integer> dispatcher = new Dispatcher<>("test", 1, Integer::longValue, 6);
List<Integer> received = dispatchWhileBlocked(dispatcher, 0);
dispatcher.receive(100);
dispatcher.receive(1);
awaitSize(received, 2);
Thread.sleep(50);
dispatcher.stop();
assertEquals(List.of(0, 100), received);
}
/**
* Test: processed elements release their weight so that the queue accepts new elements after an overflow.
*/
@Test
void weightBoundedQueueRecoversAfterOverflow() throws Exception
{
Dispatcher<Integer> dispatcher = new Dispatcher<>("test", 1, Integer::longValue, 6);
List<Integer> received = dispatchWhileBlocked(dispatcher, 10);
awaitSize(received, 4);
Thread.sleep(50);
for(int x = 0; x < 3; x++)
{
dispatcher.receive(5);
awaitSize(received, 5 + x);
}
dispatcher.stop();
assertEquals(List.of(0, 1, 2, 3, 5, 5, 5), received);
}
}