aboutsummaryrefslogtreecommitdiffstats
path: root/src/rtl_fm.c
diff options
context:
space:
mode:
authorKyle Keen <keenerd@gmail.com>2013-08-29 13:40:42 -0400
committerSteve Markgraf <steve@steve-m.de>2013-10-24 23:29:42 +0200
commit31cef2ef5525da9d2ae306a1515475b6f5c17ef0 (patch)
tree32859303cb83ca09866bdebdffdb8ed948be90be /src/rtl_fm.c
parenta6d7fff9cad25d700ea71b8f7207bee63807de2a (diff)
rtl_fm: fix buffer dump bug
Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'src/rtl_fm.c')
-rw-r--r--src/rtl_fm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rtl_fm.c b/src/rtl_fm.c
index 420655c..0d23fdc 100644
--- a/src/rtl_fm.c
+++ b/src/rtl_fm.c
@@ -70,6 +70,7 @@
#define MAXIMUM_OVERSAMPLE 16
#define MAXIMUM_BUF_LENGTH (MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH)
#define AUTO_GAIN -100
+#define BUFFER_DUMP 4096
#define FREQUENCIES_LIMIT 1000
@@ -587,7 +588,8 @@ static void optimal_settings(struct fm_state *fm, int freq, int hopping)
void full_demod(struct fm_state *fm)
{
- int i, sr, freq_next, hop = 0;
+ uint8_t dump[BUFFER_DUMP];
+ int i, sr, freq_next, n_read, hop = 0;
pthread_rwlock_wrlock(&data_rw);
rotate_90(fm->buf, fm->buf_len);
if (fm->fir_enable) {
@@ -629,7 +631,9 @@ void full_demod(struct fm_state *fm)
fm->squelch_hits = fm->conseq_squelch + 1; /* hair trigger */
/* wait for settling and flush buffer */
usleep(5000);
- rtlsdr_read_sync(dev, NULL, 4096, NULL);
+ rtlsdr_read_sync(dev, &dump, BUFFER_DUMP, &n_read);
+ if (n_read != BUFFER_DUMP) {
+ fprintf(stderr, "Error: bad retune.\n");}
}
}