From c404e331988790083056c05d81ad5dc7df6843e5 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sun, 2 Apr 2017 13:22:11 +0100 Subject: [PATCH] Drop odd-count bytes and don't try to account for them later. In cases where we do get an odd-length buffer (_very_ rare!) it seems to be more about dropped USB data and not librtlsdr giving us a partial callback; subsequent callbacks will still be aligned with the I byte first despite the odd count. --- sdr_rtlsdr.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/sdr_rtlsdr.c b/sdr_rtlsdr.c index 8b906c5..4f71c17 100644 --- a/sdr_rtlsdr.c +++ b/sdr_rtlsdr.c @@ -265,7 +265,6 @@ void rtlsdrCallback(unsigned char *buf, uint32_t len, void *ctx) { unsigned free_bufs; unsigned block_duration; - static int was_odd = 0; // paranoia!! static int dropping = 0; static uint64_t sampleCounter = 0; @@ -297,15 +296,7 @@ void rtlsdrCallback(unsigned char *buf, uint32_t len, void *ctx) { } } - if (was_odd) { - // Drop a sample so we are in sync with I/Q samples again (hopefully) - ++buf; - --len; - ++outbuf->dropped; - } - - was_odd = (len & 1); - slen = len/2; + slen = len/2; // Drops any trailing odd sample, that's OK if (free_bufs == 0 || (dropping && free_bufs < MODES_MAG_BUFFERS/2)) { // FIFO is full. Drop this block.