summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2016-12-27 19:14:35 -0500
committerScott Murray <scott.murray@konsulko.com>2016-12-27 19:14:35 -0500
commitdd5b6ee9df26b64f48b59dba702b4ca64cff4fba (patch)
treebc91c536dc11524d38a94f1fd768dd8989757fc7
parent5123e9e61c8759dbf2daa57730dbc22375a6c771 (diff)
Fix hang when stopping
Fix hang on stop reported in SPEC-379. I missed adding some required manipulation of the "do_exit" variable when I cut up the original rtl_fm.c main(), add it so that stop and a subsequent start will work. Also moved the wideband frequency tweaking logic so that the frequency will not be tweaked twice on a start after a stop. Bug-AGL: SPEC-379 Change-Id: I84f8fec75bcdf9f41f5d2cf2c74dd9a43f7ca8bf Signed-off-by: Scott Murray <scott.murray@konsulko.com>
-rw-r--r--rtl_fm.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/rtl_fm.c b/rtl_fm.c
index dcf28ce..10b86b7 100644
--- a/rtl_fm.c
+++ b/rtl_fm.c
@@ -963,6 +963,9 @@ int rtl_fm_init(uint32_t freq,
demod.deemph = 1;
demod.squelch_level = 0;
+ /* Adjust frequency for wb mode */
+ controller.freqs[0] += 16000;
+
/* Set sample rate */
demod.rate_in = sample_rate;
demod.rate_out = sample_rate;
@@ -1035,11 +1038,6 @@ void rtl_fm_start(void)
/* Reset endpoint before we start reading from it (mandatory) */
verbose_reset_buffer(dongle.dev);
- if (s->wb_mode) {
- for (i=0; i < s->freq_len; i++) {
- s->freqs[i] += 16000;}
- }
-
/* set up primary channel */
optimal_settings(s->freqs[0], demod.rate_in);
if (dongle.direct_sampling) {
@@ -1059,6 +1057,7 @@ void rtl_fm_start(void)
fprintf(stderr, "Output at %u Hz.\n", demod.rate_in/demod.post_downsample);
usleep(100000);
+ do_exit = 0;
pthread_create(&output.thread, NULL, output_thread_fn, (void *)(&output));
pthread_create(&demod.thread, NULL, demod_thread_fn, (void *)(&demod));
pthread_create(&dongle.thread, NULL, dongle_thread_fn, (void *)(&dongle));
@@ -1074,8 +1073,7 @@ void rtl_fm_set_freq(uint32_t freq)
s->freq_len = 1;
if (s->wb_mode) {
- for (i=0; i < s->freq_len; i++) {
- s->freqs[i] += 16000;}
+ s->freqs[0] += 16000;
}
optimal_settings(s->freqs[0], demod.rate_in);
@@ -1097,6 +1095,7 @@ void rtl_fm_set_freq(uint32_t freq)
void rtl_fm_stop(void)
{
rtlsdr_cancel_async(dongle.dev);
+ do_exit = 1;
pthread_join(dongle.thread, NULL);
safe_cond_signal(&demod.ready, &demod.ready_m);
pthread_join(demod.thread, NULL);