Clean up channel class

This commit is contained in:
Xavier Arteaga 2020-05-06 10:43:37 +02:00 committed by Xavier Arteaga
parent 080ef5ae9a
commit f69aad3aac
1 changed files with 80 additions and 77 deletions

View File

@ -156,14 +156,28 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS],
uint32_t len,
const srslte_timestamp_t& t)
{
// check input pointers
if (in != nullptr && out != nullptr) {
if (current_srate) {
// Early return if pointers are not enabled
if (in == nullptr || out == nullptr) {
return;
}
// For each channel
for (uint32_t i = 0; i < nof_channels; i++) {
// Check buffers are not null
if (in[i] != nullptr && out[i] != nullptr) {
// Skip iteration if any buffer is null
if (in[i] == nullptr || out[i] == nullptr) {
continue;
}
// If sampling rate is not set, copy input and skip rest of channel
if (current_srate == 0) {
if (in[i] != out[i]) {
srslte_vec_cf_copy(out[i], in[i], len);
}
continue;
}
// Copy input buffer
memcpy(buffer_in, in[i], sizeof(cf_t) * len);
srslte_vec_cf_copy(buffer_in, in[i], len);
if (hst) {
srslte_channel_hst_execute(hst, buffer_in, buffer_out, len, &t);
@ -172,27 +186,26 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS],
if (awgn) {
srslte_channel_awgn_run_c(awgn, buffer_in, buffer_out, len);
memcpy(buffer_in, buffer_out, sizeof(cf_t) * len);
srslte_vec_cf_copy(buffer_in, buffer_out, len);
}
if (fading[i]) {
srslte_channel_fading_execute(fading[i], buffer_in, buffer_out, len, t.full_secs + t.frac_secs);
memcpy(buffer_in, buffer_out, sizeof(cf_t) * len);
srslte_vec_cf_copy(buffer_in, buffer_out, len);
}
if (delay[i]) {
srslte_channel_delay_execute(delay[i], buffer_in, buffer_out, len, &t);
memcpy(buffer_in, buffer_out, sizeof(cf_t) * len);
srslte_vec_cf_copy(buffer_in, buffer_out, len);
}
if (rlf) {
srslte_channel_rlf_execute(rlf, buffer_in, buffer_out, len, &t);
memcpy(buffer_in, buffer_out, sizeof(cf_t) * len);
srslte_vec_cf_copy(buffer_in, buffer_out, len);
}
// Copy output buffer
memcpy(out[i], buffer_in, sizeof(cf_t) * len);
}
srslte_vec_cf_copy(out[i], buffer_in, len);
}
if (hst) {
@ -226,16 +239,6 @@ void channel::run(cf_t* in[SRSLTE_MAX_CHANNELS],
log_h->debug("%s\n", str.str().c_str());
}
} else {
for (uint32_t i = 0; i < nof_channels; i++) {
// Check buffers are not null
if (in[i] != nullptr && out[i] != nullptr && in[i] != out[i]) {
memcpy(out[i], in[i], sizeof(cf_t) * len);
}
}
}
}
}
void channel::set_srate(uint32_t srate)