mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-30 03:38:55 -05:00
SDRdaemon plugin: auto adaptive throttling
This commit is contained in:
parent
35db910ba9
commit
f9c13dace9
@ -43,7 +43,10 @@ SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *o
|
|||||||
m_tickCount(0),
|
m_tickCount(0),
|
||||||
m_samplesCount(0),
|
m_samplesCount(0),
|
||||||
m_timer(0),
|
m_timer(0),
|
||||||
m_throttlems(SDRDAEMON_THROTTLE_MS)
|
m_throttlems(SDRDAEMON_THROTTLE_MS),
|
||||||
|
m_readLengthSamples(0),
|
||||||
|
m_readLength(0),
|
||||||
|
m_throttleToggle(false)
|
||||||
{
|
{
|
||||||
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
|
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
|
||||||
}
|
}
|
||||||
@ -81,6 +84,7 @@ void SDRdaemonUDPHandler::start()
|
|||||||
// Need to notify the DSP engine to actually start
|
// Need to notify the DSP engine to actually start
|
||||||
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency * 1000); // Frequency in Hz for the DSP engine
|
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency * 1000); // Frequency in Hz for the DSP engine
|
||||||
DSPEngine::instance()->getInputMessageQueue()->push(notif);
|
DSPEngine::instance()->getInputMessageQueue()->push(notif);
|
||||||
|
m_elapsedTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRdaemonUDPHandler::stop()
|
void SDRdaemonUDPHandler::stop()
|
||||||
@ -200,13 +204,20 @@ void SDRdaemonUDPHandler::connectTimer(const QTimer* timer)
|
|||||||
|
|
||||||
void SDRdaemonUDPHandler::tick()
|
void SDRdaemonUDPHandler::tick()
|
||||||
{
|
{
|
||||||
// TOOD: auto throttling
|
// auto throttling
|
||||||
uint32_t readLengthSamples = (m_sdrDaemonBuffer.getSampleRate() * m_throttlems) / 1000;
|
int throttlems = m_elapsedTimer.restart();
|
||||||
uint32_t readLength = readLengthSamples * SDRdaemonBuffer::m_iqSampleSize;
|
|
||||||
|
if (throttlems != m_throttlems)
|
||||||
|
{
|
||||||
|
m_throttlems = throttlems;
|
||||||
|
m_readLengthSamples = (m_sdrDaemonBuffer.getSampleRate() * (m_throttlems+(m_throttleToggle ? 1 : 0))) / 1000;
|
||||||
|
m_readLength = m_readLengthSamples * SDRdaemonBuffer::m_iqSampleSize;
|
||||||
|
m_throttleToggle = !m_throttleToggle;
|
||||||
|
}
|
||||||
|
|
||||||
// read samples directly feeding the SampleFifo (no callback)
|
// read samples directly feeding the SampleFifo (no callback)
|
||||||
m_sampleFifo->write(reinterpret_cast<quint8*>(m_sdrDaemonBuffer.readData(readLength)), readLength);
|
m_sampleFifo->write(reinterpret_cast<quint8*>(m_sdrDaemonBuffer.readData(m_readLength)), m_readLength);
|
||||||
m_samplesCount += readLengthSamples;
|
m_samplesCount += m_readLengthSamples;
|
||||||
|
|
||||||
if (m_tickCount < m_rateDivider)
|
if (m_tickCount < m_rateDivider)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,9 @@ private:
|
|||||||
const QTimer *m_timer;
|
const QTimer *m_timer;
|
||||||
QElapsedTimer m_elapsedTimer;
|
QElapsedTimer m_elapsedTimer;
|
||||||
int m_throttlems;
|
int m_throttlems;
|
||||||
|
uint32_t m_readLengthSamples;
|
||||||
|
uint32_t m_readLength;
|
||||||
|
bool m_throttleToggle;
|
||||||
|
|
||||||
static const int m_rateDivider;
|
static const int m_rateDivider;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user