LimeSDR output: implemented common thread interface for input and output plugins to be able to start/stop thread from each other

This commit is contained in:
f4exb 2017-04-22 10:45:33 +02:00
parent 29a44a27f6
commit 9f4eeda7c9
2 changed files with 24 additions and 23 deletions

View File

@ -96,7 +96,7 @@ bool LimeSDROutput::openDevice()
busyChannels[buddyShared->m_channel] = 1; busyChannels[buddyShared->m_channel] = 1;
if (buddyShared->m_thread) { // suspend Tx buddy's thread for proper stream allocation later if (buddyShared->m_thread) { // suspend Tx buddy's thread for proper stream allocation later
((LimeSDROutputThread *) buddyShared->m_thread)->stopWork(); buddyShared->m_thread->stopWork();
} }
} }
@ -187,7 +187,7 @@ bool LimeSDROutput::openDevice()
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) { if (buddyShared->m_thread) {
((LimeSDROutputThread *) buddyShared->m_thread)->startWork(); buddyShared->m_thread->startWork();
} }
} }
@ -208,7 +208,7 @@ void LimeSDROutput::closeDevice()
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) { if (buddyShared->m_thread) {
((LimeSDROutputThread *) buddyShared->m_thread)->stopWork(); buddyShared->m_thread->stopWork();
} }
} }
@ -233,7 +233,7 @@ void LimeSDROutput::closeDevice()
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) { if (buddyShared->m_thread) {
((LimeSDROutputThread *) buddyShared->m_thread)->startWork(); buddyShared->m_thread->startWork();
} }
} }
@ -272,7 +272,7 @@ bool LimeSDROutput::start()
m_limeSDROutputThread->startWork(); m_limeSDROutputThread->startWork();
m_deviceShared.m_thread = (void *) m_limeSDROutputThread; m_deviceShared.m_thread = m_limeSDROutputThread;
m_running = true; m_running = true;
return true; return true;
@ -459,9 +459,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
for (; itSource != sourceBuddies.end(); ++itSource) for (; itSource != sourceBuddies.end(); ++itSource)
{ {
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr(); DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSource)->getBuddySharedPtr();
if (buddySharedPtr->m_thread)
{ if (buddySharedPtr->m_thread) {
((LimeSDRInputThread *) buddySharedPtr->m_thread)->stopWork(); buddySharedPtr->m_thread->stopWork();
} }
} }
@ -471,9 +471,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
for (; itSink != sinkBuddies.end(); ++itSink) for (; itSink != sinkBuddies.end(); ++itSink)
{ {
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
if (buddySharedPtr->m_thread)
{ if (buddySharedPtr->m_thread) {
((LimeSDROutputThread *) buddySharedPtr->m_thread)->stopWork(); buddySharedPtr->m_thread->stopWork();
} }
} }
@ -489,9 +489,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
for (; itSink != sinkBuddies.end(); ++itSink) for (; itSink != sinkBuddies.end(); ++itSink)
{ {
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
if (buddySharedPtr->m_thread)
{ if (buddySharedPtr->m_thread) {
((LimeSDROutputThread *) buddySharedPtr->m_thread)->stopWork(); buddySharedPtr->m_thread->stopWork();
} }
} }
@ -714,9 +714,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
for (; itSink != sinkBuddies.end(); ++itSink) for (; itSink != sinkBuddies.end(); ++itSink)
{ {
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
if (buddySharedPtr->m_thread)
{ if (buddySharedPtr->m_thread) {
((LimeSDROutputThread *) buddySharedPtr->m_thread)->startWork(); buddySharedPtr->m_thread->startWork();
} }
} }
@ -732,9 +732,9 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
for (; itSink != sinkBuddies.end(); ++itSink) for (; itSink != sinkBuddies.end(); ++itSink)
{ {
DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr(); DeviceLimeSDRShared *buddySharedPtr = (DeviceLimeSDRShared *) (*itSink)->getBuddySharedPtr();
if (buddySharedPtr->m_thread)
{ if (buddySharedPtr->m_thread) {
((LimeSDROutputThread *) buddySharedPtr->m_thread)->startWork(); buddySharedPtr->m_thread->startWork();
} }
} }

View File

@ -25,10 +25,11 @@
#include "dsp/samplesourcefifo.h" #include "dsp/samplesourcefifo.h"
#include "dsp/interpolators.h" #include "dsp/interpolators.h"
#include "limesdr/devicelimesdrshared.h"
#define LIMESDROUTPUT_BLOCKSIZE (1<<14) //complex samples per buffer ~10k (16k) #define LIMESDROUTPUT_BLOCKSIZE (1<<14) //complex samples per buffer ~10k (16k)
class LimeSDROutputThread : public QThread class LimeSDROutputThread : public QThread, public DeviceLimeSDRShared::ThreadInterface
{ {
Q_OBJECT Q_OBJECT
@ -36,8 +37,8 @@ public:
LimeSDROutputThread(lms_stream_t* stream, SampleSourceFifo* sampleFifo, QObject* parent = 0); LimeSDROutputThread(lms_stream_t* stream, SampleSourceFifo* sampleFifo, QObject* parent = 0);
~LimeSDROutputThread(); ~LimeSDROutputThread();
void startWork(); virtual void startWork();
void stopWork(); virtual void stopWork();
void setLog2Interpolation(unsigned int log2_ioterp); void setLog2Interpolation(unsigned int log2_ioterp);
void setFcPos(int fcPos); void setFcPos(int fcPos);