From 92d936568cd33e4f093abece3db10b596e0697d0 Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Tue, 29 May 2012 02:40:49 +0200 Subject: [PATCH] rtl_tcp: add parameter for changing number of buffers This is useful for devices with low memory, e.g. routers with OpenWRT (decrease to 8 for example). Signed-off-by: Steve Markgraf --- src/rtl_tcp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c index cee9036..6b63c0a 100644 --- a/src/rtl_tcp.c +++ b/src/rtl_tcp.c @@ -85,6 +85,7 @@ void usage(void) "\t[-f frequency to tune to [Hz]]\n" "\t[-g gain (default: 0 for auto)]\n" "\t[-s samplerate in Hz (default: 2048000 Hz)]\n" + "\t[-b number of buffers (default: 32, set by library)]\n" "\t[-d device index (default: 0)]\n"); exit(1); } @@ -308,7 +309,7 @@ int main(int argc, char **argv) uint32_t frequency = 100000000, samp_rate = 2048000; struct sockaddr_in local, remote; int device_count; - uint32_t dev_index = 0; + uint32_t dev_index = 0, buf_num = 0; int gain = 0; struct llist *curelem,*prev; pthread_attr_t attr; @@ -326,7 +327,7 @@ int main(int argc, char **argv) struct sigaction sigact; #endif - while ((opt = getopt(argc, argv, "a:p:f:g:s:d:")) != -1) { + while ((opt = getopt(argc, argv, "a:p:f:g:s:b:d:")) != -1) { switch (opt) { case 'd': dev_index = atoi(optarg); @@ -346,6 +347,9 @@ int main(int argc, char **argv) case 'p': port = atoi(optarg); break; + case 'b': + buf_num = atoi(optarg); + break; default: usage(); break; @@ -474,7 +478,8 @@ int main(int argc, char **argv) r = pthread_create(&command_thread, &attr, command_worker, NULL); pthread_attr_destroy(&attr); - rtlsdr_wait_async(dev, rtlsdr_callback, (void *)0); + r = rtlsdr_read_async(dev, rtlsdr_callback, (void *)0, + buf_num, 0); closesocket(s); if(!dead[0])