rf_file: close tx/rx files properly

Previously tests were failing on some machines, because
receiver was unable to receive the last few samples from file.
Reason: the transmitter did not close  the file properly, so
the last samples were (sometimes) not yet flushed to disk.
master
Robert Falkenberg 3 years ago
parent c26f2b2041
commit 6b79116805

@ -351,11 +351,13 @@ int rf_file_close(void* h)
rf_file_info(handler->id, "Closing ...\n");
// close receiver+transmitter and release related resources (except for the file handles)
for (int i = 0; i < handler->nof_channels; i++) {
rf_file_tx_close(&handler->transmitter[i]);
rf_file_rx_close(&handler->receiver[i]);
}
// release other resources
for (uint32_t i = 0; i < handler->nof_channels; i++) {
if (handler->buffer_decimation[i]) {
free(handler->buffer_decimation[i]);
@ -371,6 +373,7 @@ int rf_file_close(void* h)
pthread_mutex_destroy(&handler->decim_mutex);
pthread_mutex_destroy(&handler->rx_gain_mutex);
// now close the files if we opened them ourselves
if (handler->close_files) {
for (int i = 0; i < handler->nof_channels; i++) {
if (handler->receiver[i].file != NULL) {

@ -94,5 +94,5 @@ void rf_file_rx_close(rf_file_rx_t* q)
free(q->temp_buffer_convert);
}
q->file = NULL;
// not touching q->file as we don't know if we need to close it ourselves
}

@ -185,5 +185,5 @@ void rf_file_tx_close(rf_file_tx_t* q)
free(q->temp_buffer_convert);
}
q->file = NULL;
// not touching q->file as we don't know if we need to close it ourselves
}

Loading…
Cancel
Save