devices: reset internal smart sample buffers upon stop

They are too smart, they keep the timestamps.

Change-Id: Idb4b8f03eb5ffdfd6d3fdbc137b20e3ddc4cfa65
This commit is contained in:
Eric Wild 2020-07-16 18:08:30 +02:00
parent 1e17c4fb0a
commit 4080eb76f8
4 changed files with 22 additions and 2 deletions

View File

@ -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)

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}