aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Erckenbrecht <dg1yfe@stus-disco.de>2020-07-31 09:05:14 +0200
committerFelix Erckenbrecht <dg1yfe@stus-disco.de>2020-07-31 09:05:14 +0200
commit86813ec92f00b34d7275204e5cc215ad6e923de6 (patch)
treeb3a2be8a4bb52a9cb33be7ba9c7b478c641edd3a
parentb5708eb5ebbdaf2d80bc1f499ee9ae5f4ec5d7a2 (diff)
downloadosmo-fl2k-86813ec92f00b34d7275204e5cc215ad6e923de6.tar.gz
osmo-fl2k-86813ec92f00b34d7275204e5cc215ad6e923de6.tar.bz2
osmo-fl2k-86813ec92f00b34d7275204e5cc215ad6e923de6.zip
Lock mutex before calling cond_wait or cond_signal
-rw-r--r--src/fl2k_iq.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fl2k_iq.c b/src/fl2k_iq.c
index 7a604be..40cc28a 100644
--- a/src/fl2k_iq.c
+++ b/src/fl2k_iq.c
@@ -249,7 +249,9 @@ static void *iq_worker(void *arg)
tmp_ptr = ambuf;
ambuf = txbuf;
txbuf = tmp_ptr;
+ pthread_mutex_lock(&cb_mutex);
pthread_cond_wait(&cb_cond, &cb_mutex);
+ pthread_mutex_unlock(&cb_mutex);
}
dds_real_buf(&base_signal, ambuf, remaining);
@@ -260,7 +262,9 @@ static void *iq_worker(void *arg)
dds_real_buf(&base_signal, &ambuf[len], rf_to_baseband_sample_ratio);
len += rf_to_baseband_sample_ratio;
}
+ pthread_mutex_lock(&iq_mutex);
pthread_cond_signal(&iq_cond);
+ pthread_mutex_unlock(&iq_mutex);
}
pthread_exit(NULL);
@@ -334,7 +338,9 @@ void iq_modulator()
writepos %= BUFFER_SAMPLES;
}
} else {
+ pthread_mutex_lock(&iq_mutex);
pthread_cond_wait(&iq_cond, &iq_mutex);
+ pthread_mutex_unlock(&iq_mutex);
}
}
}
@@ -345,7 +351,9 @@ void fl2k_callback(fl2k_data_info_t *data_info)
if (data_info->device_error) {
fprintf(stderr, "Device error, exiting.\n");
do_exit = 1;
+ pthread_mutex_lock(&iq_mutex);
pthread_cond_signal(&iq_cond);
+ pthread_mutex_unlock(&iq_mutex);
}
pthread_cond_signal(&cb_cond);