Skip to content

Commit

Permalink
RTLSDR: make sure start and stop are effective once only. PArt of #2159
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Aug 27, 2024
1 parent f6b3b22 commit beaf293
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions plugins/samplesource/rtlsdr/rtlsdrinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) :

RTLSDRInput::~RTLSDRInput()
{
qDebug("RTLSDRInput::~RTLSDRInput");
QObject::disconnect(
m_networkManager,
&QNetworkAccessManager::finished,
Expand All @@ -91,6 +92,7 @@ RTLSDRInput::~RTLSDRInput()
}

closeDevice();
qDebug("RTLSDRInput::~RTLSDRInput: end");
}

void RTLSDRInput::destroy()
Expand Down Expand Up @@ -231,23 +233,27 @@ bool RTLSDRInput::start()
{
QMutexLocker mutexLocker(&m_mutex);

if (m_running) {
return true;
}

if (!m_dev) {
return false;
return false;
}

if (m_running) stop();
qDebug("RTLSDRInput::start");

m_rtlSDRThread = new RTLSDRThread(m_dev, &m_sampleFifo, &m_replayBuffer);
m_rtlSDRThread->setSamplerate(m_settings.m_devSampleRate);
m_rtlSDRThread->setLog2Decimation(m_settings.m_log2Decim);
m_rtlSDRThread->setFcPos((int) m_settings.m_fcPos);
m_rtlSDRThread->setIQOrder(m_settings.m_iqOrder);
m_rtlSDRThread->startWork();
m_running = true;

mutexLocker.unlock();

applySettings(m_settings, QList<QString>(), true);
m_running = true;

return true;
}
Expand All @@ -267,6 +273,12 @@ void RTLSDRInput::stop()
{
QMutexLocker mutexLocker(&m_mutex);

if (!m_running) {
return;
}

qDebug("RTLSDRInput::stop");

if (m_rtlSDRThread)
{
m_rtlSDRThread->stopWork();
Expand Down

0 comments on commit beaf293

Please sign in to comment.