diff --git a/Transceiver52M/device/common/smpl_buf.cpp b/Transceiver52M/device/common/smpl_buf.cpp index ceca000e..e57eb0ca 100644 --- a/Transceiver52M/device/common/smpl_buf.cpp +++ b/Transceiver52M/device/common/smpl_buf.cpp @@ -28,9 +28,9 @@ #include 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 0b49b827..ff02bafb 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 4a1f8b68..32a46e5a 100644 --- a/Transceiver52M/device/ipc/IPCDevice.cpp +++ b/Transceiver52M/device/ipc/IPCDevice.cpp @@ -980,6 +980,10 @@ bool IPCDevice::stop() LOGC(DDEV, NOTICE) << "All channels stopped, terminating..."; + /* 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 43b9f9cc..143a0616 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; }