mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-17 23:28:50 -05:00
SDRDaemon output: removed dependency on sys/time.h and unistd.h
This commit is contained in:
parent
be6e9a0bb4
commit
83069dec63
@ -14,7 +14,6 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <QDebug>
|
||||
@ -420,9 +419,9 @@ void SDRdaemonSinkOutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSetti
|
||||
|
||||
void SDRdaemonSinkOutput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
{
|
||||
struct timeval tv;
|
||||
uint64_t ts_usecs;
|
||||
response.getSdrDaemonSinkReport()->setBufferRwBalance(m_sampleSourceFifo.getRWBalance());
|
||||
response.getSdrDaemonSinkReport()->setSampleCount(m_sdrDaemonSinkThread ? (int) m_sdrDaemonSinkThread->getSamplesCount(tv) : 0);
|
||||
response.getSdrDaemonSinkReport()->setSampleCount(m_sdrDaemonSinkThread ? (int) m_sdrDaemonSinkThread->getSamplesCount(ts_usecs) : 0);
|
||||
}
|
||||
|
||||
void SDRdaemonSinkOutput::tick()
|
||||
@ -504,8 +503,8 @@ void SDRdaemonSinkOutput::analyzeApiReply(const QJsonObject& jsonObject)
|
||||
}
|
||||
|
||||
uint32_t sampleCountDelta, sampleCount;
|
||||
struct timeval tv;
|
||||
sampleCount = m_sdrDaemonSinkThread->getSamplesCount(tv);
|
||||
uint64_t timestampUs;
|
||||
sampleCount = m_sdrDaemonSinkThread->getSamplesCount(timestampUs);
|
||||
|
||||
if (sampleCount < m_lastSampleCount) {
|
||||
sampleCountDelta = (0xFFFFFFFFU - m_lastSampleCount) + sampleCount + 1;
|
||||
@ -513,8 +512,6 @@ void SDRdaemonSinkOutput::analyzeApiReply(const QJsonObject& jsonObject)
|
||||
sampleCountDelta = sampleCount - m_lastSampleCount;
|
||||
}
|
||||
|
||||
uint64_t timestampUs = tv.tv_sec*1000000ULL + tv.tv_usec;
|
||||
|
||||
// on initial state wait for queue stabilization
|
||||
if ((m_lastRemoteTimestampRateCorrection == 0) && (queueLength >= m_lastQueueLength-1) && (queueLength <= m_lastQueueLength+1))
|
||||
{
|
||||
|
@ -14,7 +14,6 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
@ -22,6 +21,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "dsp/samplesourcefifo.h"
|
||||
#include "util/timeutil.h"
|
||||
#include "sdrdaemonsinkthread.h"
|
||||
|
||||
SDRdaemonSinkThread::SDRdaemonSinkThread(SampleSourceFifo* sampleFifo, QObject* parent) :
|
||||
@ -140,8 +140,8 @@ void SDRdaemonSinkThread::tick()
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t SDRdaemonSinkThread::getSamplesCount(struct timeval& tv) const
|
||||
uint32_t SDRdaemonSinkThread::getSamplesCount(uint64_t& ts_usecs) const
|
||||
{
|
||||
gettimeofday(&tv, 0);
|
||||
ts_usecs = TimeUtil::nowus();
|
||||
return m_samplesCount;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
bool isRunning() const { return m_running; }
|
||||
|
||||
uint32_t getSamplesCount(struct timeval& tv) const;
|
||||
uint32_t getSamplesCount(uint64_t& ts_usecs) const;
|
||||
void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; }
|
||||
void setChunkCorrection(int chunkCorrection) { m_chunkCorrection = chunkCorrection; }
|
||||
|
||||
|
@ -16,11 +16,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <boost/crc.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include "util/timeutil.h"
|
||||
#include "udpsinkfec.h"
|
||||
#include "udpsinkfecworker.h"
|
||||
|
||||
@ -118,10 +117,9 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk
|
||||
|
||||
if (m_txBlockIndex == 0) // Tx block index 0 is a block with only meta data
|
||||
{
|
||||
struct timeval tv;
|
||||
SDRDaemonMetaDataFEC metaData;
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
uint64_t ts_usecs = TimeUtil::nowus();
|
||||
|
||||
metaData.m_centerFrequency = 0; // frequency not set by stream
|
||||
metaData.m_sampleRate = m_sampleRate;
|
||||
@ -129,8 +127,8 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk
|
||||
metaData.m_sampleBits = SDR_RX_SAMP_SZ;
|
||||
metaData.m_nbOriginalBlocks = m_nbOriginalBlocks;
|
||||
metaData.m_nbFECBlocks = m_nbBlocksFEC;
|
||||
metaData.m_tv_sec = tv.tv_sec;
|
||||
metaData.m_tv_usec = tv.tv_usec;
|
||||
metaData.m_tv_sec = ts_usecs / 1000000UL;
|
||||
metaData.m_tv_usec = ts_usecs % 1000000UL;
|
||||
|
||||
boost::crc_32_type crc32;
|
||||
crc32.process_bytes(&metaData, 20);
|
||||
|
@ -25,3 +25,13 @@ uint64_t TimeUtil::nowms()
|
||||
|
||||
return value.count();
|
||||
}
|
||||
|
||||
uint64_t TimeUtil::nowus()
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto now_ms = std::chrono::time_point_cast<std::chrono::microseconds>(now);
|
||||
auto epoch = now_ms.time_since_epoch();
|
||||
auto value = std::chrono::duration_cast<std::chrono::microseconds>(epoch);
|
||||
|
||||
return value.count();
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ class SDRBASE_API TimeUtil
|
||||
{
|
||||
public:
|
||||
static uint64_t nowms(); //!< returns the current epoch in milliseconds
|
||||
static uint64_t nowus(); //!< returns the current epoch in microseconds
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user