diff --git a/devices/limesdr/devicelimesdrshared.h b/devices/limesdr/devicelimesdrshared.h index dc26f6977..90926bfa5 100644 --- a/devices/limesdr/devicelimesdrshared.h +++ b/devices/limesdr/devicelimesdrshared.h @@ -25,9 +25,16 @@ */ struct DeviceLimeSDRShared { + class ThreadInterface + { + public: + virtual void startWork() = 0; + virtual void stopWork() = 0; + }; + DeviceLimeSDRParams *m_deviceParams; //!< unique hardware device parameters std::size_t m_channel; //!< logical device channel number (-1 if none) - void *m_thread; //!< anonymous pointer that will hold the thread address if started else 0 + ThreadInterface *m_thread; //!< holds the thread address if started else 0 int m_ncoFrequency; uint64_t m_centerFrequency; diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index f1f119948..99ddff811 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -106,7 +106,7 @@ bool LimeSDRInput::openDevice() busyChannels[buddyShared->m_channel] = 1; if (buddyShared->m_thread) { // suspend Rx buddy's thread for proper stream allocation later - ((LimeSDRInputThread *) buddyShared->m_thread)->stopWork(); + buddyShared->m_thread->stopWork(); } } @@ -197,7 +197,7 @@ bool LimeSDRInput::openDevice() DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); if (buddyShared->m_thread) { - ((LimeSDRInputThread *) buddyShared->m_thread)->startWork(); + buddyShared->m_thread->startWork(); } } @@ -218,7 +218,7 @@ void LimeSDRInput::closeDevice() DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); if (buddyShared->m_thread) { - ((LimeSDRInputThread *) buddyShared->m_thread)->stopWork(); + buddyShared->m_thread->stopWork(); } } @@ -243,7 +243,7 @@ void LimeSDRInput::closeDevice() DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); if (buddyShared->m_thread) { - ((LimeSDRInputThread *) buddyShared->m_thread)->startWork(); + buddyShared->m_thread->startWork(); } } @@ -282,7 +282,7 @@ bool LimeSDRInput::start() m_limeSDRInputThread->startWork(); - m_deviceShared.m_thread = (void *) m_limeSDRInputThread; + m_deviceShared.m_thread = m_limeSDRInputThread; m_running = true; return true; @@ -469,9 +469,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSource != sourceBuddies.end(); ++itSource) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->stopWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->stopWork(); } } @@ -481,9 +481,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSink != sinkBuddies.end(); ++itSink) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->stopWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->stopWork(); } } @@ -499,9 +499,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSource != sourceBuddies.end(); ++itSource) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->stopWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->stopWork(); } } @@ -724,9 +724,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSource != sourceBuddies.end(); ++itSource) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->startWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->startWork(); } } @@ -736,9 +736,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSink != sinkBuddies.end(); ++itSink) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->startWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->startWork(); } } @@ -754,9 +754,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc for (; itSource != sourceBuddies.end(); ++itSource) { DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); - if (buddySharedPtr->m_thread) - { - ((LimeSDRInputThread *) buddySharedPtr->m_thread)->startWork(); + + if (buddySharedPtr->m_thread) { + buddySharedPtr->m_thread->startWork(); } } diff --git a/plugins/samplesource/limesdrinput/limesdrinputthread.h b/plugins/samplesource/limesdrinput/limesdrinputthread.h index 21c1b7915..f01b80649 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputthread.h +++ b/plugins/samplesource/limesdrinput/limesdrinputthread.h @@ -25,10 +25,11 @@ #include "dsp/samplesinkfifo.h" #include "dsp/decimators.h" +#include "limesdr/devicelimesdrshared.h" #define LIMESDR_BLOCKSIZE (1<<14) //complex samples per buffer ~10k (16k) -class LimeSDRInputThread : public QThread +class LimeSDRInputThread : public QThread, public DeviceLimeSDRShared::ThreadInterface { Q_OBJECT @@ -36,8 +37,8 @@ public: LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sampleFifo, QObject* parent = 0); ~LimeSDRInputThread(); - void startWork(); - void stopWork(); + virtual void startWork(); + virtual void stopWork(); void setLog2Decimation(unsigned int log2_decim); void setFcPos(int fcPos);