mirror of https://github.com/f4exb/sdrangel.git
LimeSDR: implemented common thread interface for input and output plugins to be able to start/stop thread from each other
This commit is contained in:
parent
f447c9f9bd
commit
29a44a27f6
|
@ -25,9 +25,16 @@
|
||||||
*/
|
*/
|
||||||
struct DeviceLimeSDRShared
|
struct DeviceLimeSDRShared
|
||||||
{
|
{
|
||||||
|
class ThreadInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void startWork() = 0;
|
||||||
|
virtual void stopWork() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
DeviceLimeSDRParams *m_deviceParams; //!< unique hardware device parameters
|
DeviceLimeSDRParams *m_deviceParams; //!< unique hardware device parameters
|
||||||
std::size_t m_channel; //!< logical device channel number (-1 if none)
|
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;
|
int m_ncoFrequency;
|
||||||
uint64_t m_centerFrequency;
|
uint64_t m_centerFrequency;
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ bool LimeSDRInput::openDevice()
|
||||||
busyChannels[buddyShared->m_channel] = 1;
|
busyChannels[buddyShared->m_channel] = 1;
|
||||||
|
|
||||||
if (buddyShared->m_thread) { // suspend Rx buddy's thread for proper stream allocation later
|
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();
|
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
|
||||||
|
|
||||||
if (buddyShared->m_thread) {
|
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();
|
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
|
||||||
|
|
||||||
if (buddyShared->m_thread) {
|
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();
|
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
|
||||||
|
|
||||||
if (buddyShared->m_thread) {
|
if (buddyShared->m_thread) {
|
||||||
((LimeSDRInputThread *) buddyShared->m_thread)->startWork();
|
buddyShared->m_thread->startWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ bool LimeSDRInput::start()
|
||||||
|
|
||||||
m_limeSDRInputThread->startWork();
|
m_limeSDRInputThread->startWork();
|
||||||
|
|
||||||
m_deviceShared.m_thread = (void *) m_limeSDRInputThread;
|
m_deviceShared.m_thread = m_limeSDRInputThread;
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -469,9 +469,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,9 +481,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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) {
|
||||||
((LimeSDRInputThread *) buddySharedPtr->m_thread)->stopWork();
|
buddySharedPtr->m_thread->stopWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,9 +499,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,9 +724,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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)->startWork();
|
buddySharedPtr->m_thread->startWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,9 +736,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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) {
|
||||||
((LimeSDRInputThread *) buddySharedPtr->m_thread)->startWork();
|
buddySharedPtr->m_thread->startWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,9 +754,9 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||||
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)->startWork();
|
buddySharedPtr->m_thread->startWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,11 @@
|
||||||
|
|
||||||
#include "dsp/samplesinkfifo.h"
|
#include "dsp/samplesinkfifo.h"
|
||||||
#include "dsp/decimators.h"
|
#include "dsp/decimators.h"
|
||||||
|
#include "limesdr/devicelimesdrshared.h"
|
||||||
|
|
||||||
#define LIMESDR_BLOCKSIZE (1<<14) //complex samples per buffer ~10k (16k)
|
#define LIMESDR_BLOCKSIZE (1<<14) //complex samples per buffer ~10k (16k)
|
||||||
|
|
||||||
class LimeSDRInputThread : public QThread
|
class LimeSDRInputThread : public QThread, public DeviceLimeSDRShared::ThreadInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -36,8 +37,8 @@ public:
|
||||||
LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sampleFifo, QObject* parent = 0);
|
LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sampleFifo, QObject* parent = 0);
|
||||||
~LimeSDRInputThread();
|
~LimeSDRInputThread();
|
||||||
|
|
||||||
void startWork();
|
virtual void startWork();
|
||||||
void stopWork();
|
virtual void stopWork();
|
||||||
void setLog2Decimation(unsigned int log2_decim);
|
void setLog2Decimation(unsigned int log2_decim);
|
||||||
void setFcPos(int fcPos);
|
void setFcPos(int fcPos);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue