rf_imp: fix stopping of AGC thread

hard killing of AGC thread causes issue on some RF devices,
such as the N310. The thread still seemed to access the device while
the radio was already killed (or the streamer object deleted).

It's unclear why this isn't causing similar issues on B210 or X310,
at least not visible, but it is obviously not the correct way to stop a thread.

The patch now correctly sets the stop flag for the AGC thread, wakes it
it up and waits until it has terminated.
master
Andre Puschmann 4 years ago
parent 7495986b5c
commit 43a6cd50e5

@ -58,7 +58,7 @@ static void* thread_gain_fcn(void* h)
while (rf->thread_gain_run) {
pthread_mutex_lock(&rf->mutex);
while (rf->cur_rx_gain == rf->new_rx_gain) {
while (rf->cur_rx_gain == rf->new_rx_gain && rf->thread_gain_run) {
pthread_cond_wait(&rf->cond, &rf->mutex);
}
if (rf->new_rx_gain != rf->cur_rx_gain) {
@ -184,7 +184,8 @@ int srslte_rf_close(srslte_rf_t* rf)
{
// Stop gain thread
if (rf->thread_gain_run) {
pthread_cancel(rf->thread_gain);
rf->thread_gain_run = false;
pthread_cond_signal(&rf->cond);
pthread_join(rf->thread_gain, NULL);
}

Loading…
Cancel
Save