mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-21 19:09:22 -04:00
TestMOSync: updated threading model. Part of #1346
This commit is contained in:
parent
0e236f8acc
commit
9e4fe95bba
plugins/samplemimo
@ -22,6 +22,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QBuffer>
|
||||
#include <QThread>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QByteArray>
|
||||
#include <QTimer>
|
||||
#include <QNetworkRequest>
|
||||
#include <QThread>
|
||||
|
||||
#include "dsp/devicesamplemimo.h"
|
||||
#include "testmisettings.h"
|
||||
@ -31,6 +30,7 @@ class DeviceAPI;
|
||||
class TestMIWorker;
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class QThread;
|
||||
|
||||
class TestMI : public DeviceSampleMIMO {
|
||||
Q_OBJECT
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
#include <QThread>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
@ -42,6 +43,7 @@ TestMOSync::TestMOSync(DeviceAPI *deviceAPI) :
|
||||
m_spectrumVis(SDR_TX_SCALEF),
|
||||
m_settings(),
|
||||
m_sinkWorker(nullptr),
|
||||
m_sinkWorkerThread(nullptr),
|
||||
m_deviceDescription("TestMOSync"),
|
||||
m_runningTx(false),
|
||||
m_masterTimer(deviceAPI->getMasterTimer()),
|
||||
@ -68,15 +70,20 @@ void TestMOSync::init()
|
||||
|
||||
bool TestMOSync::startTx()
|
||||
{
|
||||
qDebug("TestMOSync::startTx");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_runningTx) {
|
||||
stopTx();
|
||||
return true;
|
||||
}
|
||||
|
||||
qDebug("TestMOSync::startTx");
|
||||
m_sinkWorkerThread = new QThread();
|
||||
m_sinkWorker = new TestMOSyncWorker();
|
||||
m_sinkWorker->moveToThread(&m_sinkWorkerThread);
|
||||
m_sinkWorker->moveToThread(m_sinkWorkerThread);
|
||||
|
||||
QObject::connect(m_sinkWorkerThread, &QThread::finished, m_sinkWorker, &QObject::deleteLater);
|
||||
QObject::connect(m_sinkWorkerThread, &QThread::finished, m_sinkWorkerThread, &QThread::deleteLater);
|
||||
|
||||
m_sampleMOFifo.reset();
|
||||
m_sinkWorker->setFifo(&m_sampleMOFifo);
|
||||
m_sinkWorker->setFcPos(m_settings.m_fcPosTx);
|
||||
@ -94,31 +101,31 @@ bool TestMOSync::startTx()
|
||||
|
||||
void TestMOSync::stopTx()
|
||||
{
|
||||
qDebug("TestMOSync::stopTx");
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (!m_sinkWorker) {
|
||||
if (!m_runningTx) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
qDebug("TestMOSync::stopTx");
|
||||
m_runningTx = false;
|
||||
|
||||
stopWorker();
|
||||
delete m_sinkWorker;
|
||||
m_sinkWorker = nullptr;
|
||||
m_runningTx = false;
|
||||
m_sinkWorkerThread = nullptr;
|
||||
}
|
||||
|
||||
void TestMOSync::startWorker()
|
||||
{
|
||||
m_sinkWorker->startWork();
|
||||
m_sinkWorkerThread.start();
|
||||
m_sinkWorkerThread->start();
|
||||
}
|
||||
|
||||
void TestMOSync::stopWorker()
|
||||
{
|
||||
m_sinkWorker->stopWork();
|
||||
m_sinkWorkerThread.quit();
|
||||
m_sinkWorkerThread.wait();
|
||||
m_sinkWorkerThread->quit();
|
||||
m_sinkWorkerThread->wait();
|
||||
}
|
||||
|
||||
QByteArray TestMOSync::serialize() const
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
|
||||
#include "dsp/devicesamplemimo.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
@ -32,6 +31,7 @@
|
||||
class DeviceAPI;
|
||||
class TestMOSyncWorker;
|
||||
class BasebandSampleSink;
|
||||
class QThread;
|
||||
|
||||
class TestMOSync : public DeviceSampleMIMO {
|
||||
Q_OBJECT
|
||||
@ -153,8 +153,8 @@ private:
|
||||
QMutex m_mutex;
|
||||
SpectrumVis m_spectrumVis;
|
||||
TestMOSyncSettings m_settings;
|
||||
TestMOSyncWorker* m_sinkWorker;
|
||||
QThread m_sinkWorkerThread;
|
||||
TestMOSyncWorker *m_sinkWorker;
|
||||
QThread *m_sinkWorkerThread;
|
||||
QString m_deviceDescription;
|
||||
bool m_runningTx;
|
||||
const QTimer& m_masterTimer;
|
||||
|
Loading…
Reference in New Issue
Block a user