1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 10:33:29 -05:00

BladerRF2 input support (8). Streams but thread issue

This commit is contained in:
f4exb 2018-09-25 08:45:57 +02:00
parent b20feec1fd
commit 47a4da4142
5 changed files with 21 additions and 8 deletions

View File

@ -32,7 +32,7 @@ public:
class InputThreadInterface class InputThreadInterface
{ {
public: public:
virtual ~InputThreadInterface() = 0; virtual ~InputThreadInterface() {}
virtual void startWork() = 0; virtual void startWork() = 0;
virtual void stopWork() = 0; virtual void stopWork() = 0;
virtual bool isRunning() const = 0; virtual bool isRunning() const = 0;
@ -48,7 +48,7 @@ public:
class OutputThreadInterface class OutputThreadInterface
{ {
public: public:
virtual ~OutputThreadInterface() = 0; virtual ~OutputThreadInterface() {}
virtual void startWork() = 0; virtual void startWork() = 0;
virtual void stopWork() = 0; virtual void stopWork() = 0;
virtual bool isRunning() = 0; virtual bool isRunning() = 0;

View File

@ -42,7 +42,8 @@ BladeRF2Input::BladeRF2Input(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
m_settings(), m_settings(),
m_deviceDescription("BladeRF2Input"), m_deviceDescription("BladeRF2Input"),
m_running(false) m_running(false),
m_thread(0)
{ {
openDevice(); openDevice();
@ -313,11 +314,13 @@ void BladeRF2Input::stop()
} }
int nbOriginalChannels = m_deviceShared.m_inputThread->getNbChannels(); int nbOriginalChannels = m_deviceShared.m_inputThread->getNbChannels();
Bladerf2InputThread *bladerf2InputThread = 0;
if (nbOriginalChannels == 1) // SI mode if (nbOriginalChannels == 1) // SI mode
{ {
m_deviceShared.m_inputThread->stopWork(); m_deviceShared.m_inputThread->stopWork();
delete m_deviceShared.m_inputThread; bladerf2InputThread = (Bladerf2InputThread*) m_deviceShared.m_inputThread;
delete bladerf2InputThread;
m_deviceShared.m_inputThread = 0; m_deviceShared.m_inputThread = 0;
m_running = false; m_running = false;
} }
@ -334,8 +337,10 @@ void BladeRF2Input::stop()
fcPoss[i] = m_deviceShared.m_inputThread->getFcPos(i); fcPoss[i] = m_deviceShared.m_inputThread->getFcPos(i);
} }
delete m_deviceShared.m_inputThread; bladerf2InputThread = (Bladerf2InputThread*) m_deviceShared.m_inputThread;
m_deviceShared.m_inputThread = new Bladerf2InputThread(m_deviceShared.m_dev->getDev(), nbOriginalChannels-1); delete bladerf2InputThread;
bladerf2InputThread = new Bladerf2InputThread(m_deviceShared.m_dev->getDev(), nbOriginalChannels-1);
m_deviceShared.m_inputThread = bladerf2InputThread;
for (int i = 0; i < nbOriginalChannels-1; i++) { // restore original FIFO references for (int i = 0; i < nbOriginalChannels-1; i++) { // restore original FIFO references
m_deviceShared.m_inputThread->setFifo(i, fifos[i]); m_deviceShared.m_inputThread->setFifo(i, fifos[i]);

View File

@ -26,7 +26,7 @@
#include "bladerf2inputsettings.h" #include "bladerf2inputsettings.h"
class DeviceSourceAPI; class DeviceSourceAPI;
class LimeSDRInputThread; class BladeRF2InputThread;
class FileRecord; class FileRecord;
class BladeRF2Input : public DeviceSampleSource class BladeRF2Input : public DeviceSampleSource
@ -147,6 +147,7 @@ private:
QString m_deviceDescription; QString m_deviceDescription;
bool m_running; bool m_running;
DeviceBladeRF2Shared m_deviceShared; DeviceBladeRF2Shared m_deviceShared;
BladeRF2InputThread *m_thread;
FileRecord *m_fileSink; //!< File sink to record device I/Q output FileRecord *m_fileSink; //!< File sink to record device I/Q output
bool openDevice(); bool openDevice();

View File

@ -23,11 +23,18 @@ Bladerf2InputThread::Bladerf2InputThread(struct bladerf* dev, unsigned int nbRxC
m_nbChannels(nbRxChannels) m_nbChannels(nbRxChannels)
{ {
m_channels = new Channel[nbRxChannels]; m_channels = new Channel[nbRxChannels];
for (unsigned int i = 0; i < nbRxChannels; i++) {
m_channels[i].m_convertBuffer.resize(DeviceBladeRF2::blockSize, Sample{0,0});
}
m_buf = new qint16[2*DeviceBladeRF2::blockSize*nbRxChannels]; m_buf = new qint16[2*DeviceBladeRF2::blockSize*nbRxChannels];
} }
Bladerf2InputThread::~Bladerf2InputThread() Bladerf2InputThread::~Bladerf2InputThread()
{ {
qDebug("Bladerf2InputThread::~Bladerf2InputThread");
if (m_running) { if (m_running) {
stopWork(); stopWork();
} }

View File

@ -37,7 +37,7 @@ class Bladerf2InputThread : public QThread, public DeviceBladeRF2Shared::InputTh
public: public:
Bladerf2InputThread(struct bladerf* dev, unsigned int nbRxChannels, QObject* parent = NULL); Bladerf2InputThread(struct bladerf* dev, unsigned int nbRxChannels, QObject* parent = NULL);
virtual ~Bladerf2InputThread(); ~Bladerf2InputThread();
virtual void startWork(); virtual void startWork();
virtual void stopWork(); virtual void stopWork();