1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-03 06:24:48 -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
committed by Edouard Griffiths
parent 1b37a4f504
commit 585d806ef8
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);