uhd: smpl_buf: Drop UHD specifics out back to UHDDevice

This way smpl_buf can be re-used later by other non-UHD drivers.

Change-Id: I94061328d46a550d4147121d85baffa29c700c45
This commit is contained in:
Pau Espin Pedrol
2019-04-29 17:46:34 +02:00
parent 7bef2346c4
commit 87b7d098e5
3 changed files with 4 additions and 25 deletions

View File

@@ -759,7 +759,7 @@ int uhd_device::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
for (size_t i = 0; i < rx_buffers.size(); i++) {
rc = rx_buffers[i]->write((short *) &pkt_bufs[i].front(),
num_smpls,
metadata.time_spec);
metadata.time_spec.to_ticks(rx_rate));
// Continue on local overrun, exit on other errors
if ((rc < 0)) {

View File

@@ -47,11 +47,6 @@ ssize_t smpl_buf::avail_smpls(TIMESTAMP timestamp) const
return time_end - timestamp;
}
ssize_t smpl_buf::avail_smpls(uhd::time_spec_t timespec) const
{
return avail_smpls(timespec.to_ticks(clk_rt));
}
ssize_t smpl_buf::read(void *buf, size_t len, TIMESTAMP timestamp)
{
int type_sz = 2 * sizeof(short);
@@ -93,11 +88,6 @@ ssize_t smpl_buf::read(void *buf, size_t len, TIMESTAMP timestamp)
return num_smpls;
}
ssize_t smpl_buf::read(void *buf, size_t len, uhd::time_spec_t ts)
{
return read(buf, len, ts.to_ticks(clk_rt));
}
ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
{
int type_sz = 2 * sizeof(short);
@@ -110,14 +100,12 @@ ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
if (timestamp < time_end) {
LOGC(DDEV, ERR) << "Overwriting old buffer data: timestamp="<<timestamp<<" time_end="<<time_end;
uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(timestamp, clk_rt);
LOGC(DDEV, DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << ts.to_ticks(clk_rt) << ") rate=" << clk_rt;
LOGC(DDEV, DEBUG) << "Requested timestamp = " << timestamp << " rate=" << clk_rt;
// Do not return error here, because it's a rounding error and is not fatal
}
if (timestamp > time_end && time_end != 0) {
LOGC(DDEV, ERR) << "Skipping buffer data: timestamp="<<timestamp<<" time_end="<<time_end;
uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(timestamp, clk_rt);
LOGC(DDEV, DEBUG) << "Requested timestamp = " << timestamp << " (real_sec=" << std::fixed << ts.get_real_secs() << " = " << ts.to_ticks(clk_rt) << ") rate=" << clk_rt;
LOGC(DDEV, DEBUG) << "Requested timestamp = " << timestamp << " rate=" << clk_rt;
// Do not return error here, because it's a rounding error and is not fatal
}
@@ -150,11 +138,6 @@ ssize_t smpl_buf::write(void *buf, size_t len, TIMESTAMP timestamp)
return len;
}
ssize_t smpl_buf::write(void *buf, size_t len, uhd::time_spec_t ts)
{
return write(buf, len, ts.to_ticks(clk_rt));
}
std::string smpl_buf::str_status(size_t ts) const
{
std::ostringstream ost("Sample buffer: ");

View File

@@ -25,13 +25,12 @@
#pragma once
#include <unistd.h>
#include <uhd/types/time_spec.hpp>
#include "radioDevice.h"
/*
Sample Buffer - Allows reading and writing of timed samples using osmo-trx
or UHD style timestamps. Time conversions are handled
timestamps. Time conversions are handled
internally or accessable through the static convert calls.
*/
class smpl_buf {
@@ -49,7 +48,6 @@ public:
@return number of available samples or error
*/
ssize_t avail_smpls(TIMESTAMP timestamp) const;
ssize_t avail_smpls(uhd::time_spec_t timestamp) const;
/** Read and write
@param buf pointer to buffer
@@ -58,9 +56,7 @@ public:
@return number of actual samples read or written or error
*/
ssize_t read(void *buf, size_t len, TIMESTAMP timestamp);
ssize_t read(void *buf, size_t len, uhd::time_spec_t timestamp);
ssize_t write(void *buf, size_t len, TIMESTAMP timestamp);
ssize_t write(void *buf, size_t len, uhd::time_spec_t timestamp);
/** Buffer status string
@return a formatted string describing internal buffer state