1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-30 03:38:55 -05:00

SDRdaemonFEC plugin: take buffering into account for timestamp calculation

This commit is contained in:
f4exb 2016-07-24 12:53:39 +02:00
parent bbccea9432
commit 5e14ac9173
3 changed files with 23 additions and 2 deletions

View File

@ -46,6 +46,8 @@ SDRdaemonFECBuffer::SDRdaemonFECBuffer(uint32_t throttlems) :
m_currentMeta.init();
m_framesNbBytes = nbDecoderSlots * sizeof(BufferFrame);
m_wrDeltaEstimate = m_framesNbBytes / 2;
m_tvOut_sec = 0;
m_tvOut_usec = 0;
m_readNbBytes = 1;
m_paramsCM256.BlockBytes = sizeof(ProtectedBlock); // never changes
m_paramsCM256.OriginalCount = m_nbOriginalBlocks; // never changes
@ -169,6 +171,17 @@ void SDRdaemonFECBuffer::checkSlotData(int slotIndex)
m_wrDeltaEstimate = pseudoWriteIndex - m_readIndex;
m_nbWrites++;
int rwDelayBytes = (m_wrDeltaEstimate > 0 ? m_wrDeltaEstimate : sizeof(BufferFrame) * nbDecoderSlots + m_wrDeltaEstimate);
int sampleRate = m_currentMeta.m_sampleRate;
if (sampleRate > 0)
{
int64_t ts = m_currentMeta.m_tv_sec * 1000000LL + m_currentMeta.m_tv_usec;
ts -= (rwDelayBytes * 1000000LL) / (sampleRate * sizeof(Sample));
m_tvOut_sec = ts / 1000000LL;
m_tvOut_usec = ts - (m_tvOut_sec * 1000000LL);
}
if (!m_decoderSlots[slotIndex].m_decoded)
{
qDebug() << "SDRdaemonFECBuffer::checkSlotData: incomplete frame:"

View File

@ -92,6 +92,10 @@ public:
// meta data
const MetaDataFEC& getCurrentMeta() const { return m_currentMeta; }
// samples timestamp
uint32_t getTVOutSec() const { return m_tvOut_sec; }
uint32_t getTVOutUsec() const { return m_tvOut_usec; }
// stats
int getCurNbBlocks() const { return m_curNbBlocks; }
@ -187,6 +191,8 @@ private:
bool m_framesDecoded; //!< [stats] true if all frames were decoded since last poll
int m_readIndex; //!< current byte read index in frames buffer
int m_wrDeltaEstimate; //!< Sampled estimate of write to read indexes difference
uint32_t m_tvOut_sec; //!< Estimated returned samples timestamp (seconds)
uint32_t m_tvOut_usec; //!< Estimated returned samples timestamp (microseconds)
int m_readNbBytes; //!< Nominal number of bytes per read (50ms)
uint32_t m_throttlemsNominal; //!< Initial throttle in ms

View File

@ -149,8 +149,10 @@ void SDRdaemonFECUDPHandler::processData()
const SDRdaemonFECBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
bool change = false;
m_tv_sec = metaData.m_tv_sec;
m_tv_usec = metaData.m_tv_usec;
// m_tv_sec = metaData.m_tv_sec;
// m_tv_usec = metaData.m_tv_usec;
m_tv_sec = m_sdrDaemonBuffer.getTVOutSec();
m_tv_usec = m_sdrDaemonBuffer.getTVOutUsec();
if (m_centerFrequency != metaData.m_centerFrequency)
{