1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-07-25 03:24:18 -04:00

All device plugins: make sure start and stop are effective once only. PArt of #2159

This commit is contained in:
f4exb
2024-08-21 05:27:01 +02:00
parent 38043ebdbc
commit 3a7de65ee5
40 changed files with 454 additions and 243 deletions
@@ -142,6 +142,12 @@ void BladeRF2MIMO::init()
bool BladeRF2MIMO::startRx()
{
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
return true;
}
qDebug("BladeRF2MIMO::startRx");
if (!m_open)
@@ -150,12 +156,6 @@ bool BladeRF2MIMO::startRx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
stopRx();
}
m_sourceThread = new BladeRF2MIThread(m_dev->getDev());
m_sampleMIFifo.reset();
m_sourceThread->setFifo(&m_sampleMIFifo);
@@ -178,6 +178,12 @@ bool BladeRF2MIMO::startRx()
bool BladeRF2MIMO::startTx()
{
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
return true;
}
qDebug("BladeRF2MIMO::startTx");
if (!m_open)
@@ -186,12 +192,6 @@ bool BladeRF2MIMO::startTx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
stopTx();
}
m_sinkThread = new BladeRF2MOThread(m_dev->getDev());
m_sampleMOFifo.reset();
m_sinkThread->setFifo(&m_sampleMOFifo);
@@ -213,18 +213,22 @@ bool BladeRF2MIMO::startTx()
void BladeRF2MIMO::stopRx()
{
qDebug("BladeRF2MIMO::stopRx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningRx) {
return;
}
if (!m_sourceThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("BladeRF2MIMO::stopRx");
m_runningRx = false;
m_sourceThread->stopWork();
delete m_sourceThread;
m_sourceThread = nullptr;
m_runningRx = false;
for (int i = 0; i < 2; i++) {
m_dev->closeRx(i);
@@ -233,18 +237,22 @@ void BladeRF2MIMO::stopRx()
void BladeRF2MIMO::stopTx()
{
qDebug("BladeRF2MIMO::stopTx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningTx) {
return;
}
if (!m_sinkThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("BladeRF2MIMO::stopTx");
m_runningTx = false;
m_sinkThread->stopWork();
delete m_sinkThread;
m_sinkThread = nullptr;
m_runningTx = false;
for (int i = 0; i < 2; i++) {
m_dev->closeTx(i);
+26 -18
View File
@@ -256,6 +256,12 @@ void LimeSDRMIMO::init()
bool LimeSDRMIMO::startRx()
{
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
return true;
}
qDebug("LimeSDRMIMO::startRx");
lms_stream_t *streams[2];
@@ -265,12 +271,6 @@ bool LimeSDRMIMO::startRx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
stopRx();
}
for (unsigned int channel = 0; channel < 2; channel++)
{
if (channel < m_deviceAPI->getNbSourceStreams())
@@ -307,18 +307,22 @@ bool LimeSDRMIMO::startRx()
void LimeSDRMIMO::stopRx()
{
qDebug("LimeSDRMIMO::stopRx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningRx) {
return;
}
if (!m_sourceThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("LimeSDRMIMO::stopRx");
m_runningRx = false;
m_sourceThread->stopWork();
delete m_sourceThread;
m_sourceThread = nullptr;
m_runningRx = false;
for (unsigned int channel = 0; channel < 2; channel++)
{
@@ -330,6 +334,12 @@ void LimeSDRMIMO::stopRx()
bool LimeSDRMIMO::startTx()
{
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
return true;
}
qDebug("LimeSDRMIMO::startTx");
lms_stream_t *streams[2];
@@ -339,12 +349,6 @@ bool LimeSDRMIMO::startTx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
stopTx();
}
for (unsigned int channel = 0; channel < 2; channel++)
{
if (channel < m_deviceAPI->getNbSinkStreams())
@@ -380,18 +384,22 @@ bool LimeSDRMIMO::startTx()
void LimeSDRMIMO::stopTx()
{
qDebug("LimeSDRMIMO::stopTx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningTx) {
return;
}
if (!m_sinkThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("LimeSDRMIMO::stopTx");
m_runningTx = false;
m_sinkThread->stopWork();
delete m_sinkThread;
m_sinkThread = nullptr;
m_runningTx = false;
for (unsigned int channel = 0; channel < 2; channel++)
{
@@ -168,7 +168,11 @@ void PlutoSDRMIMO::init()
bool PlutoSDRMIMO::startRx()
{
qDebug("PlutoSDRMIMO::startRx");
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
return true;
}
if (!m_open)
{
@@ -176,11 +180,7 @@ bool PlutoSDRMIMO::startRx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
stopRx();
}
qDebug("PlutoSDRMIMO::startRx");
m_sourceThread = new PlutoSDRMIThread(m_plutoParams->getBox());
m_sampleMIFifo.reset();
@@ -206,7 +206,11 @@ bool PlutoSDRMIMO::startRx()
bool PlutoSDRMIMO::startTx()
{
qDebug("PlutoSDRMIMO::startTx");
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
return true;
}
if (!m_open)
{
@@ -214,11 +218,7 @@ bool PlutoSDRMIMO::startTx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
stopTx();
}
qDebug("PlutoSDRMIMO::startTx");
m_sinkThread = new PlutoSDRMOThread(m_plutoParams->getBox());
m_sampleMOFifo.reset();
@@ -243,18 +243,22 @@ bool PlutoSDRMIMO::startTx()
void PlutoSDRMIMO::stopRx()
{
qDebug("PlutoSDRMIMO::stopRx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningRx) {
return;
}
if (!m_sourceThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("PlutoSDRMIMO::stopRx");
m_runningRx = false;
m_sourceThread->stopWork();
delete m_sourceThread;
m_sourceThread = nullptr;
m_runningRx = false;
if (m_nbRx > 1) {
m_plutoParams->getBox()->closeSecondRx();
@@ -270,18 +274,22 @@ void PlutoSDRMIMO::stopRx()
void PlutoSDRMIMO::stopTx()
{
qDebug("PlutoSDRMIMO::stopTx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningTx) {
return;
}
if (!m_sinkThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("PlutoSDRMIMO::stopTx");
m_runningTx = false;
m_sinkThread->stopWork();
delete m_sinkThread;
m_sinkThread = nullptr;
m_runningTx = false;
if (m_nbTx > 1) {
m_plutoParams->getBox()->closeSecondTx();
+1 -1
View File
@@ -127,7 +127,7 @@ void TestMI::stopRx()
}
qDebug("TestMI::stopRx");
m_running = false;
m_running = false;
stopWorkers();
m_testSourceWorkers.clear();
+26 -18
View File
@@ -124,7 +124,11 @@ void XTRXMIMO::init()
bool XTRXMIMO::startRx()
{
qDebug("XTRXMIMO::startRx");
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
return true;
}
if (!m_open)
{
@@ -132,11 +136,7 @@ bool XTRXMIMO::startRx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
stopRx();
}
qDebug("XTRXMIMO::startRx");
m_sourceThread = new XTRXMIThread(m_deviceShared.m_dev->getDevice());
m_sampleMIFifo.reset();
@@ -152,7 +152,11 @@ bool XTRXMIMO::startRx()
bool XTRXMIMO::startTx()
{
qDebug("XTRXMIMO::startTx");
QMutexLocker mutexLocker(&m_mutex);
if (m_runningTx) {
return true;
}
if (!m_open)
{
@@ -160,11 +164,7 @@ bool XTRXMIMO::startTx()
return false;
}
QMutexLocker mutexLocker(&m_mutex);
if (m_runningRx) {
stopRx();
}
qDebug("XTRXMIMO::startTx");
m_sinkThread = new XTRXMOThread(m_deviceShared.m_dev->getDevice());
m_sampleMOFifo.reset();
@@ -179,34 +179,42 @@ bool XTRXMIMO::startTx()
void XTRXMIMO::stopRx()
{
qDebug("XTRXMIMO::stopRx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningRx){
return;
}
if (!m_sourceThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("XTRXMIMO::stopRx");
m_runningRx = false;
m_sourceThread->stopWork();
delete m_sourceThread;
m_sourceThread = nullptr;
m_runningRx = false;
}
void XTRXMIMO::stopTx()
{
qDebug("XTRXMIMO::stopTx");
QMutexLocker mutexLocker(&m_mutex);
if (!m_runningTx) {
return;
}
if (!m_sinkThread) {
return;
}
QMutexLocker mutexLocker(&m_mutex);
qDebug("XTRXMIMO::stopTx");
m_runningTx = false;
m_sinkThread->stopWork();
delete m_sinkThread;
m_sinkThread = nullptr;
m_runningTx = false;
}
QByteArray XTRXMIMO::serialize() const