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.
This commit is contained in:
Andre Puschmann 2020-11-17 14:07:57 +01:00
parent 95f75b8523
commit ff84d77799
1 changed files with 3 additions and 2 deletions

View File

@ -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);
}