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

PlutoSDR input: fill sample FIFO only when convert buffer is full

This commit is contained in:
f4exb 2017-09-08 08:41:57 +02:00
parent 868cac90f0
commit 450a44036e
3 changed files with 42 additions and 30 deletions

View File

@ -26,7 +26,7 @@
#include "plutosdrinput.h"
#include "plutosdrinputthread.h"
#define PLUTOSDR_BLOCKSIZE (1024*1024) //complex samples per buffer
#define PLUTOSDR_BLOCKSIZE (1024*1024) //complex samples per buffer (must be multiple of 64)
MESSAGE_CLASS_DEFINITION(PlutoSDRInput::MsgFileRecord, Message)
@ -381,20 +381,21 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
}
}
std::vector<std::string> params;
bool paramsToSet = false;
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{
int64_t newXO = plutoBox->getInitialXO() + ((plutoBox->getInitialXO()*settings.m_LOppmTenths) / 10000000L);
std::vector<std::string> params;
params.push_back(QString(tr("xo_correction=%1").arg(newXO)).toStdString());
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
paramsToSet = true;
}
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force)
{
std::vector<std::string> params;
params.push_back(QString(tr("out_altvoltage0_RX_LO_frequency=%1").arg(settings.m_centerFrequency)).toStdString());
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
paramsToSet = true;
forwardChangeOwnDSP = true;
}
@ -402,7 +403,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
{
std::vector<std::string> params;
params.push_back(QString(tr("in_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString());
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
paramsToSet = true;
}
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
@ -411,7 +412,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
QString rfPortStr;
PlutoSDRInputSettings::translateRFPath(settings.m_antennaPath, rfPortStr);
params.push_back(QString(tr("in_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString());
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
paramsToSet = true;
}
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
@ -420,13 +421,18 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
QString gainModeStr;
PlutoSDRInputSettings::translateGainMode(settings.m_gainMode, gainModeStr);
params.push_back(QString(tr("in_voltage0_gain_control_mode=%1").arg(gainModeStr)).toStdString());
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
paramsToSet = true;
}
if ((m_settings.m_gain != settings.m_gain) || force)
{
std::vector<std::string> params;
params.push_back(QString(tr("in_voltage0_hardwaregain=%1").arg(settings.m_gain)).toStdString());
paramsToSet = true;
}
if (paramsToSet)
{
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
}

View File

@ -25,6 +25,7 @@ PlutoSDRInputThread::PlutoSDRInputThread(uint32_t blocksize, DevicePlutoSDRBox*
m_blockSize(blocksize),
m_convertBuffer(blocksize),
m_sampleFifo(sampleFifo),
m_convertIt(m_convertBuffer.begin()),
m_log2Decim(0),
m_fcPos(PlutoSDRInputSettings::FC_POS_CENTER)
{
@ -110,11 +111,9 @@ void PlutoSDRInputThread::run()
// Decimate according to specified log2 (ex: log2=4 => decim=16)
void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
{
SampleVector::iterator it = m_convertBuffer.begin();
if (m_log2Decim == 0)
{
m_decimators.decimate1(&it, buf, len);
m_decimators.decimate1(&m_convertIt, buf, len);
}
else
{
@ -123,22 +122,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_inf(&it, buf, len);
m_decimators.decimate2_inf(&m_convertIt, buf, len);
break;
case 2:
m_decimators.decimate4_inf(&it, buf, len);
m_decimators.decimate4_inf(&m_convertIt, buf, len);
break;
case 3:
m_decimators.decimate8_inf(&it, buf, len);
m_decimators.decimate8_inf(&m_convertIt, buf, len);
break;
case 4:
m_decimators.decimate16_inf(&it, buf, len);
m_decimators.decimate16_inf(&m_convertIt, buf, len);
break;
case 5:
m_decimators.decimate32_inf(&it, buf, len);
m_decimators.decimate32_inf(&m_convertIt, buf, len);
break;
case 6:
m_decimators.decimate64_inf(&it, buf, len);
m_decimators.decimate64_inf(&m_convertIt, buf, len);
break;
default:
break;
@ -149,22 +148,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_sup(&it, buf, len);
m_decimators.decimate2_sup(&m_convertIt, buf, len);
break;
case 2:
m_decimators.decimate4_sup(&it, buf, len);
m_decimators.decimate4_sup(&m_convertIt, buf, len);
break;
case 3:
m_decimators.decimate8_sup(&it, buf, len);
m_decimators.decimate8_sup(&m_convertIt, buf, len);
break;
case 4:
m_decimators.decimate16_sup(&it, buf, len);
m_decimators.decimate16_sup(&m_convertIt, buf, len);
break;
case 5:
m_decimators.decimate32_sup(&it, buf, len);
m_decimators.decimate32_sup(&m_convertIt, buf, len);
break;
case 6:
m_decimators.decimate64_sup(&it, buf, len);
m_decimators.decimate64_sup(&m_convertIt, buf, len);
break;
default:
break;
@ -175,22 +174,22 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
switch (m_log2Decim)
{
case 1:
m_decimators.decimate2_cen(&it, buf, len);
m_decimators.decimate2_cen(&m_convertIt, buf, len);
break;
case 2:
m_decimators.decimate4_cen(&it, buf, len);
m_decimators.decimate4_cen(&m_convertIt, buf, len);
break;
case 3:
m_decimators.decimate8_cen(&it, buf, len);
m_decimators.decimate8_cen(&m_convertIt, buf, len);
break;
case 4:
m_decimators.decimate16_cen(&it, buf, len);
m_decimators.decimate16_cen(&m_convertIt, buf, len);
break;
case 5:
m_decimators.decimate32_cen(&it, buf, len);
m_decimators.decimate32_cen(&m_convertIt, buf, len);
break;
case 6:
m_decimators.decimate64_cen(&it, buf, len);
m_decimators.decimate64_cen(&m_convertIt, buf, len);
break;
default:
break;
@ -198,6 +197,12 @@ void PlutoSDRInputThread::convert(const qint16* buf, qint32 len)
}
}
m_sampleFifo->write(m_convertBuffer.begin(), it);
++m_convertIt;
if (m_convertIt == m_convertBuffer.end())
{
m_sampleFifo->write(m_convertBuffer.begin(), m_convertBuffer.end());
m_convertIt = m_convertBuffer.begin();
}
}

View File

@ -52,6 +52,7 @@ private:
uint32_t m_blockSize;
SampleVector m_convertBuffer;
SampleSinkFifo* m_sampleFifo;
SampleVector::iterator m_convertIt;
unsigned int m_log2Decim; // soft decimation
int m_fcPos;