aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-08-30 20:52:22 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 10:30:06 +0200
commit1f1515296813e6cd7f47c0c3186da7111dec7dca (patch)
treed552f3f3a6762c17b989313d822857912457cc3d
parent21ce05c54f16f44c70dfc32ea445589502ea7d89 (diff)
radioInterfaceMulti:pullBuffer: Sanely convert float array to complex array
Fixes this type of compilation warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] Change-Id: Ibb2380a0a335ce798fe87221519fbbebade53054
-rw-r--r--Transceiver52M/radioInterfaceMulti.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/Transceiver52M/radioInterfaceMulti.cpp b/Transceiver52M/radioInterfaceMulti.cpp
index 67ccb25..17a015b 100644
--- a/Transceiver52M/radioInterfaceMulti.cpp
+++ b/Transceiver52M/radioInterfaceMulti.cpp
@@ -230,6 +230,7 @@ int RadioInterfaceMulti::pullBuffer()
bool local_underrun;
size_t num;
float *buf;
+ unsigned int i;
if (recvBuffer[0]->getFreeSegments() <= 0)
return -1;
@@ -273,10 +274,22 @@ int RadioInterfaceMulti::pullBuffer()
buf = channelizer->outputBuffer(pchan);
size_t cLen = channelizer->outputLen();
size_t hLen = dnsampler->len();
- size_t hSize = 2 * hLen * sizeof(float);
- memcpy(&buf[2 * -hLen], history[lchan]->begin(), hSize);
- memcpy(history[lchan]->begin(), &buf[2 * (cLen - hLen)], hSize);
+ float *fdst = &buf[2 * -hLen];
+ complex *src = history[lchan]->begin();
+ for (i = 0; i < hLen; i++) {
+ fdst[0] = src->real();
+ fdst[1] = src->imag();
+ src++;
+ fdst += 2;
+ }
+ complex *dst = history[lchan]->begin();
+ float *fsrc = &buf[2 * (cLen - hLen)];
+ for (i = 0; i < hLen; i++) {
+ *dst = complex(fdst[0], fdst[1]);
+ fsrc += 2;
+ dst++;
+ }
float *wr_segment = recvBuffer[lchan]->getWriteSegment();