mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-17 23:28:50 -05:00
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
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user