1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04: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
@@ -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();
}
}