1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

SDRDaemonSink: wait for queue stabilization to start rate control

This commit is contained in:
f4exb 2018-09-07 09:22:17 +02:00
parent 98a1f1952f
commit 4518984ddb
2 changed files with 6 additions and 1 deletions

View File

@ -58,6 +58,7 @@ SDRdaemonSinkOutput::SDRdaemonSinkOutput(DeviceSinkAPI *deviceAPI) :
m_lastSampleCount(0),
m_lastRemoteTimestampRateCorrection(0),
m_lastTimestampRateCorrection(0),
m_lastQueueLength(-2),
m_nbRemoteSamplesSinceRateCorrection(0),
m_nbSamplesSinceRateCorrection(0),
m_chunkSizeCorrection(0)
@ -93,6 +94,7 @@ bool SDRdaemonSinkOutput::start()
m_lastRemoteTimestampRateCorrection = 0;
m_lastTimestampRateCorrection = 0;
m_lastQueueLength = -2; // set first value out of bounds
double delay = ((127*127*m_settings.m_txDelay) / m_settings.m_sampleRate)/(128 + m_settings.m_nbFECBlocks);
m_sdrDaemonSinkThread->setTxDelay((int) (delay*1e6));
@ -514,7 +516,8 @@ void SDRdaemonSinkOutput::analyzeApiReply(const QJsonObject& jsonObject)
uint64_t timestampUs = tv.tv_sec*1000000ULL + tv.tv_usec;
if (m_lastRemoteTimestampRateCorrection == 0)
// on initial state wait for queue stabilization
if ((m_lastRemoteTimestampRateCorrection == 0) && (queueLength >= m_lastQueueLength-1) && (queueLength <= m_lastQueueLength+1))
{
m_lastRemoteTimestampRateCorrection = remoteTimestampUs;
m_lastTimestampRateCorrection = timestampUs;
@ -545,6 +548,7 @@ void SDRdaemonSinkOutput::analyzeApiReply(const QJsonObject& jsonObject)
m_lastRemoteSampleCount = remoteSampleCount;
m_lastSampleCount = sampleCount;
m_lastQueueLength = queueLength;
}
}

View File

@ -183,6 +183,7 @@ private:
uint32_t m_lastSampleCount;
uint64_t m_lastRemoteTimestampRateCorrection;
uint64_t m_lastTimestampRateCorrection;
int m_lastQueueLength;
uint32_t m_nbRemoteSamplesSinceRateCorrection;
uint32_t m_nbSamplesSinceRateCorrection;
int m_chunkSizeCorrection;