SDRdaemon plugin: use internal (slower) timer for Windows release only

This commit is contained in:
Edouard Griffiths 2016-03-16 18:46:16 +01:00
parent 8a44f5c089
commit be13c80e73
3 changed files with 20 additions and 8 deletions

View File

@ -35,3 +35,5 @@ LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
LIBS += -L../../../lz4/$${build_subdir} -llz4
RESOURCES = ../../../sdrbase/resources/res.qrc
CONFIG(MINGW32):DEFINES += USE_INTERNAL_TIMER=1

View File

@ -23,8 +23,6 @@
#include "sdrdaemonudphandler.h"
#include "sdrdaemoninput.h"
const int SDRdaemonUDPHandler::m_rateDivider = 1000/SDRDAEMON_THROTTLE_MS;
SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) :
m_sdrDaemonBuffer(m_rateDivider),
m_dataSocket(0),
@ -45,7 +43,8 @@ SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *o
m_throttlems(SDRDAEMON_THROTTLE_MS),
m_readLengthSamples(0),
m_readLength(0),
m_throttleToggle(false)
m_throttleToggle(false),
m_rateDivider(1000/SDRDAEMON_THROTTLE_MS)
{
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
}
@ -54,6 +53,11 @@ SDRdaemonUDPHandler::~SDRdaemonUDPHandler()
{
stop();
delete[] m_udpBuf;
#ifdef USE_INTERNAL_TIMER
if (m_timer) {
delete m_timer;
}
#endif
}
void SDRdaemonUDPHandler::start()
@ -192,9 +196,16 @@ void SDRdaemonUDPHandler::setSamplerate(uint32_t samplerate)
void SDRdaemonUDPHandler::connectTimer(const QTimer* timer)
{
qDebug() << "SDRdaemonUDPHandler::connectTimer";
#ifdef USE_INTERNAL_TIMER
#warning "Uses internal timer"
m_timer = new QTimer();
m_timer->start(100);
#else
m_timer = timer;
m_throttlems = timer->interval();
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
#endif
m_throttlems = m_timer->interval();
m_rateDivider = 1000 / m_throttlems;
connect(m_timer, SIGNAL(timeout()), this, SLOT(tick()));
}
void SDRdaemonUDPHandler::tick()

View File

@ -61,15 +61,14 @@ private:
MessageQueue *m_outputMessageQueueToGUI;
uint32_t m_tickCount;
std::size_t m_samplesCount;
const QTimer *m_timer;
QTimer *m_timer;
QElapsedTimer m_elapsedTimer;
int m_throttlems;
uint32_t m_readLengthSamples;
uint32_t m_readLength;
bool m_throttleToggle;
static const int m_rateDivider;
int m_rateDivider;
void setSamplerate(uint32_t samplerate);
void processData();