1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

HackRF output: suspend thread when baseband sample rate changes

This commit is contained in:
f4exb 2017-08-08 21:30:04 +02:00
parent 287bf8120d
commit 7b851e8326
2 changed files with 27 additions and 1 deletions

View File

@ -214,11 +214,31 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
{ {
// QMutexLocker mutexLocker(&m_mutex); // QMutexLocker mutexLocker(&m_mutex);
bool forwardChange = false; bool forwardChange = false;
bool suspendThread = false;
bool threadWasRunning = false;
hackrf_error rc; hackrf_error rc;
qDebug() << "HackRFOutput::applySettings"; qDebug() << "HackRFOutput::applySettings";
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
(m_settings.m_log2Interp != settings.m_log2Interp) || force)
{
suspendThread = true;
}
if (suspendThread)
{
if (m_hackRFThread)
{
if (m_hackRFThread->isRunning())
{
m_hackRFThread->stopWork();
threadWasRunning = true;
}
}
}
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force) if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force)
{ {
forwardChange = true; forwardChange = true;
@ -339,6 +359,11 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
} }
} }
if (threadWasRunning)
{
m_hackRFThread->startWork();
}
m_settings.m_devSampleRate = settings.m_devSampleRate; m_settings.m_devSampleRate = settings.m_devSampleRate;
m_settings.m_log2Interp = settings.m_log2Interp; m_settings.m_log2Interp = settings.m_log2Interp;
m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_centerFrequency = settings.m_centerFrequency;

View File

@ -47,6 +47,7 @@ void HackRFOutputThread::startWork()
void HackRFOutputThread::stopWork() void HackRFOutputThread::stopWork()
{ {
if (!m_running) return;
qDebug("HackRFOutputThread::stopWork"); qDebug("HackRFOutputThread::stopWork");
m_running = false; m_running = false;
wait(); wait();