fix: RTL-SDR bug fixes and accuracy improvements

This commit is contained in:
2026-07-03 10:36:41 +02:00
parent 108538f60c
commit daa17a325f
5 changed files with 201 additions and 47 deletions
+9 -1
View File
@@ -155,7 +155,12 @@ namespace Drivers::Radio::Sdr {
uint32_t space = RING_BYTES - r.count;
uint32_t n = len;
uint32_t dropped = 0;
if (n > space) { dropped = n - space; n = space; }
if (n > space) {
// Truncate to a whole number of I/Q byte pairs: dropping an odd
// count would swap I and Q for the rest of the stream.
n = space & ~1u;
dropped = len - n;
}
uint32_t first = RING_BYTES - r.head;
if (first > n) first = n;
@@ -241,6 +246,9 @@ namespace Drivers::Radio::Sdr {
int Start(int handle) {
Receiver* r = Lookup(handle, true);
if (!r) return -1;
// Already streaming: a second Start must not re-arm the driver's
// transfer pool (it would double-queue every buffer).
if (r->streaming) return 0;
r->lock.Acquire();
r->head = r->count = 0; // discard stale samples before (re)starting