diff options
author | Eric <ewild@sysmocom.de> | 2020-07-16 18:08:30 +0200 |
---|---|---|
committer | Eric <ewild@sysmocom.de> | 2020-08-26 17:35:18 +0200 |
commit | 6ada823b1a124f3e28199cd42bda311822b2640b (patch) | |
tree | 85acb273bfadcd19e08bebb48061e95f8911f1bb | |
parent | a8d3e915907cf017453525a8cb8c13e2985bbcc0 (diff) |
devices: reset internal smart sample buffers upon stop
They are too smart, they keep the timestamps.
Change-Id: Idb4b8f03eb5ffdfd6d3fdbc137b20e3ddc4cfa65
-rw-r--r-- | Transceiver52M/device/common/smpl_buf.cpp | 12 | ||||
-rw-r--r-- | Transceiver52M/device/common/smpl_buf.h | 4 | ||||
-rw-r--r-- | Transceiver52M/device/ipc/IPCDevice.cpp | 4 | ||||
-rw-r--r-- | Transceiver52M/device/uhd/UHDDevice.cpp | 4 |
4 files changed, 22 insertions, 2 deletions
diff --git a/Transceiver52M/device/common/smpl_buf.cpp b/Transceiver52M/device/common/smpl_buf.cpp index ceca000..e57eb0c 100644 --- a/Transceiver52M/device/common/smpl_buf.cpp +++ b/Transceiver52M/device/common/smpl_buf.cpp @@ -28,9 +28,9 @@ #include <inttypes.h> smpl_buf::smpl_buf(size_t len) - : buf_len(len), time_start(0), time_end(0), - data_start(0), data_end(0) + : buf_len(len) { + reset(); data = new uint32_t[len]; } @@ -39,6 +39,14 @@ smpl_buf::~smpl_buf() delete[] data; } +void smpl_buf::reset() +{ + time_start = 0; + time_end = 0; + data_start = 0; + data_end = 0; +} + ssize_t smpl_buf::avail_smpls(TIMESTAMP timestamp) const { if (timestamp < time_start) diff --git a/Transceiver52M/device/common/smpl_buf.h b/Transceiver52M/device/common/smpl_buf.h index 0b49b82..ff02baf 100644 --- a/Transceiver52M/device/common/smpl_buf.h +++ b/Transceiver52M/device/common/smpl_buf.h @@ -44,6 +44,10 @@ public: smpl_buf(size_t len); ~smpl_buf(); + /** Reset this buffer, keeps the size + */ + void reset(); + /** Query number of samples available for reading @param timestamp time of first sample @return number of available samples or error diff --git a/Transceiver52M/device/ipc/IPCDevice.cpp b/Transceiver52M/device/ipc/IPCDevice.cpp index 35e0a17..febd668 100644 --- a/Transceiver52M/device/ipc/IPCDevice.cpp +++ b/Transceiver52M/device/ipc/IPCDevice.cpp @@ -940,6 +940,10 @@ bool IPCDevice::stop() else LOGC(DDEV, NOTICE) << "All chanels stopped, termianting..."; + /* reset internal buffer timestamps */ + for (size_t i = 0; i < rx_buffers.size(); i++) + rx_buffers[i]->reset(); + started = false; return true; } diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index 037f3d9..b6845fa 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -750,6 +750,10 @@ bool uhd_device::stop() async_event_thrd->join(); delete async_event_thrd; + /* reset internal buffer timestamps */ + for (size_t i = 0; i < rx_buffers.size(); i++) + rx_buffers[i]->reset(); + started = false; return true; } |