1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

BladeRF output: suspend thread when baseband sample rate changes

This commit is contained in:
f4exb 2017-08-08 23:09:51 +02:00
parent 3a9eec8463
commit 5829519116
2 changed files with 27 additions and 15 deletions

View File

@ -216,30 +216,37 @@ bool BladerfOutput::handleMessage(const Message& message)
bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool force) bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool force)
{ {
bool forwardChange = false; bool forwardChange = false;
bool suspendOwnThread = false;
bool threadWasRunning = false;
// QMutexLocker mutexLocker(&m_mutex); // QMutexLocker mutexLocker(&m_mutex);
qDebug() << "BladerfOutput::applySettings: m_dev: " << m_dev; qDebug() << "BladerfOutput::applySettings: m_dev: " << m_dev;
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
(m_settings.m_log2Interp != settings.m_log2Interp) || force)
{
suspendOwnThread = true;
}
if (suspendOwnThread)
{
if (m_bladerfThread)
{
if (m_bladerfThread->isRunning())
{
m_bladerfThread->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)
{ {
bool wasRunning = false;
if ((m_bladerfThread != 0) && (m_bladerfThread->isRunning()))
{
m_bladerfThread->stopWork();
wasRunning = true;
}
// FIFO size: // FIFO size:
// 1 s length up to interpolation by 16 // 1 s length up to interpolation by 16
// 2 s for interpolation by 32 // 2 s for interpolation by 32
m_sampleSourceFifo.resize(settings.m_devSampleRate/(1<<(settings.m_log2Interp <= 4 ? settings.m_log2Interp : 4))); m_sampleSourceFifo.resize(settings.m_devSampleRate/(1<<(settings.m_log2Interp <= 4 ? settings.m_log2Interp : 4)));
if (wasRunning)
{
m_bladerfThread->startWork();
}
} }
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
@ -416,6 +423,11 @@ bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool fo
} }
} }
if (threadWasRunning)
{
m_bladerfThread->startWork();
}
m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_centerFrequency = settings.m_centerFrequency;
m_settings.m_bandwidth = settings.m_bandwidth; m_settings.m_bandwidth = settings.m_bandwidth;
m_settings.m_xb200Filter = settings.m_xb200Filter; m_settings.m_xb200Filter = settings.m_xb200Filter;

View File

@ -222,7 +222,7 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
qDebug() << "HackRFOutput::applySettings"; qDebug() << "HackRFOutput::applySettings";
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
(m_settings.m_log2Interp != settings.m_log2Interp) || force) (m_settings.m_log2Interp != settings.m_log2Interp) || force)
{ {
suspendThread = true; suspendThread = true;
} }