mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-08-15 07:55:26 -04:00
SampleSourceFifo refactoring and Tx code reorganization
This commit is contained in:
@@ -15,12 +15,14 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "iio.h"
|
||||
|
||||
#include "dsp/samplesourcefifo.h"
|
||||
#include "plutosdr/deviceplutosdrbox.h"
|
||||
#include "plutosdroutputsettings.h"
|
||||
#include "iio.h"
|
||||
#include "plutosdroutputthread.h"
|
||||
|
||||
PlutoSDROutputThread::PlutoSDROutputThread(uint32_t blocksizeSamples, DevicePlutoSDRBox* plutoBox, SampleSourceFifoDB* sampleFifo, QObject* parent) :
|
||||
PlutoSDROutputThread::PlutoSDROutputThread(uint32_t blocksizeSamples, DevicePlutoSDRBox* plutoBox, SampleSourceFifo* sampleFifo, QObject* parent) :
|
||||
QThread(parent),
|
||||
m_running(false),
|
||||
m_plutoBox(plutoBox),
|
||||
@@ -29,7 +31,6 @@ PlutoSDROutputThread::PlutoSDROutputThread(uint32_t blocksizeSamples, DevicePlut
|
||||
m_log2Interp(0)
|
||||
{
|
||||
m_buf = new qint16[blocksizeSamples*2];
|
||||
// m_bufConv = new qint16[blocksizeSamples*(sizeof(Sample)/sizeof(qint16))];
|
||||
}
|
||||
|
||||
PlutoSDROutputThread::~PlutoSDROutputThread()
|
||||
@@ -44,8 +45,11 @@ void PlutoSDROutputThread::startWork()
|
||||
|
||||
m_startWaitMutex.lock();
|
||||
start();
|
||||
while(!m_running)
|
||||
|
||||
while(!m_running) {
|
||||
m_startWaiter.wait(&m_startWaitMutex, 100);
|
||||
}
|
||||
|
||||
m_startWaitMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -115,9 +119,25 @@ void PlutoSDROutputThread::run()
|
||||
void PlutoSDROutputThread::convert(qint16* buf, qint32 len)
|
||||
{
|
||||
// pull samples from baseband generator
|
||||
SampleVector::iterator beginRead;
|
||||
m_sampleFifo->readAdvance(beginRead, len/(2*(1<<m_log2Interp)));
|
||||
beginRead -= len/(2*(1<<m_log2Interp));
|
||||
SampleVector& data = m_sampleFifo->getData();
|
||||
unsigned int iPart1Begin, iPart1End, iPart2Begin, iPart2End;
|
||||
m_sampleFifo->read(len/(2*(1<<m_log2Interp)), iPart1Begin, iPart1End, iPart2Begin, iPart2End);
|
||||
|
||||
if (iPart1Begin != iPart1End) {
|
||||
convertPart(buf, data, iPart1Begin, iPart1End);
|
||||
}
|
||||
|
||||
unsigned int shift = (iPart1End - iPart1Begin)*(1<<m_log2Interp);
|
||||
|
||||
if (iPart2Begin != iPart2End) {
|
||||
convertPart(buf + 2*shift, data, iPart2Begin, iPart2End);
|
||||
}
|
||||
}
|
||||
|
||||
void PlutoSDROutputThread::convertPart(qint16* buf, SampleVector& data, unsigned int iBegin, unsigned int iEnd)
|
||||
{
|
||||
SampleVector::iterator beginRead = data.begin() + iBegin;
|
||||
int len = 2*(iEnd - iBegin)*(1<<m_log2Interp);
|
||||
|
||||
if (m_log2Interp == 0)
|
||||
{
|
||||
@@ -149,5 +169,4 @@ void PlutoSDROutputThread::convert(qint16* buf, qint32 len)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user