mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
MIMO engine: use SampleSinkVectors instead of SampleSinkFIFOs
This commit is contained in:
parent
9401e12643
commit
6dae67d5b1
@ -50,8 +50,7 @@ TestMI::TestMI(DeviceAPI *deviceAPI) :
|
||||
m_masterTimer(deviceAPI->getMasterTimer())
|
||||
{
|
||||
m_mimoType = MIMOAsynchronous;
|
||||
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
|
||||
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
|
||||
m_sampleSinkFifos.resize(2);
|
||||
m_deviceAPI->setNbSourceStreams(2);
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(TestMIThread::MsgStartStop, Message)
|
||||
|
||||
TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent) :
|
||||
TestMIThread::TestMIThread(SampleSinkVector* sampleFifo, int streamIndex, QObject* parent) :
|
||||
QThread(parent),
|
||||
m_running(false),
|
||||
m_buf(0),
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include "dsp/samplesinkfifo.h"
|
||||
#include "dsp/samplesinkvector.h"
|
||||
#include "dsp/decimators.h"
|
||||
#include "dsp/ncof.h"
|
||||
#include "util/message.h"
|
||||
@ -58,7 +58,7 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent = 0);
|
||||
TestMIThread(SampleSinkVector* sampleFifo, int streamIndex, QObject* parent = 0);
|
||||
~TestMIThread();
|
||||
|
||||
void startStop(bool start);
|
||||
@ -89,7 +89,7 @@ private:
|
||||
quint32 m_bufsize;
|
||||
quint32 m_chunksize;
|
||||
SampleVector m_convertBuffer;
|
||||
SampleSinkFifo* m_sampleFifo;
|
||||
SampleSinkVector* m_sampleFifo;
|
||||
int m_streamIndex;
|
||||
NCOF m_nco;
|
||||
NCOF m_toneNco;
|
||||
|
@ -52,7 +52,7 @@ SampleSourceFifo* DeviceSampleMIMO::getSampleSourceFifo(unsigned int index)
|
||||
}
|
||||
}
|
||||
|
||||
SampleSinkFifo* DeviceSampleMIMO::getSampleSinkFifo(unsigned int index)
|
||||
SampleSinkVector* DeviceSampleMIMO::getSampleSinkFifo(unsigned int index)
|
||||
{
|
||||
if (index >= m_sampleSinkFifos.size()) {
|
||||
return nullptr;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "samplesourcefifo.h"
|
||||
#include "samplesinkfifo.h"
|
||||
#include "samplesinkvector.h"
|
||||
#include "util/message.h"
|
||||
#include "util/messagequeue.h"
|
||||
#include "export.h"
|
||||
@ -133,7 +133,7 @@ public:
|
||||
unsigned int getNbSourceFifos() const { return m_sampleSourceFifos.size(); } //!< Get the number of Tx FIFOs
|
||||
unsigned int getNbSinkFifos() const { return m_sampleSinkFifos.size(); } //!< Get the number of Rx FIFOs
|
||||
SampleSourceFifo* getSampleSourceFifo(unsigned int index); //!< Get Tx FIFO at index
|
||||
SampleSinkFifo* getSampleSinkFifo(unsigned int index); //!< Get Rx FIFO at index
|
||||
SampleSinkVector* getSampleSinkFifo(unsigned int index); //!< Get Rx FIFO at index
|
||||
// Streams and FIFOs are in opposed source/sink type whick makes it confusing when stream direction is involved:
|
||||
// Rx: source stream -> sink FIFO -> channel sinks
|
||||
// Tx: sink stream <- source FIFO <- channel sources
|
||||
@ -146,7 +146,7 @@ protected slots:
|
||||
protected:
|
||||
MIMOType m_mimoType;
|
||||
std::vector<SampleSourceFifo> m_sampleSourceFifos; //!< Tx FIFOs
|
||||
std::vector<SampleSinkFifo> m_sampleSinkFifos; //!< Rx FIFOs
|
||||
std::vector<SampleSinkVector> m_sampleSinkFifos; //!< Rx FIFOs
|
||||
MessageQueue m_inputMessageQueue; //!< Input queue to the sink
|
||||
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI
|
||||
};
|
||||
|
@ -254,79 +254,35 @@ QString DSPDeviceMIMOEngine::deviceDescription()
|
||||
*/
|
||||
void DSPDeviceMIMOEngine::workSampleSink(unsigned int sinkIndex)
|
||||
{
|
||||
SampleSinkFifo* sampleFifo = m_deviceSampleMIMO->getSampleSinkFifo(sinkIndex);
|
||||
int samplesDone = 0;
|
||||
SampleSinkVector* sampleFifo = m_deviceSampleMIMO->getSampleSinkFifo(sinkIndex);
|
||||
SampleVector::iterator vbegin;
|
||||
SampleVector::iterator vend;
|
||||
bool positiveOnly = false;
|
||||
sampleFifo->read(vbegin, vend);
|
||||
|
||||
while ((sampleFifo->fill() > 0) && (m_inputMessageQueue.size() == 0) && (samplesDone < m_deviceSampleMIMO->getSourceSampleRate(sinkIndex)))
|
||||
{
|
||||
SampleVector::iterator part1begin;
|
||||
SampleVector::iterator part1end;
|
||||
SampleVector::iterator part2begin;
|
||||
SampleVector::iterator part2end;
|
||||
// DC and IQ corrections
|
||||
if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) {
|
||||
iqCorrections(vbegin, vend, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection);
|
||||
}
|
||||
|
||||
std::size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end);
|
||||
// feed data to direct sinks
|
||||
if (sinkIndex < m_basebandSampleSinks.size())
|
||||
{
|
||||
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[sinkIndex].begin(); it != m_basebandSampleSinks[sinkIndex].end(); ++it) {
|
||||
(*it)->feed(vbegin, vend, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// first part of FIFO data
|
||||
if (part1begin != part1end)
|
||||
{
|
||||
// DC and IQ corrections
|
||||
if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) {
|
||||
iqCorrections(part1begin, part1end, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection);
|
||||
}
|
||||
// possibly feed data to spectrum sink
|
||||
if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) {
|
||||
m_spectrumSink->feed(vbegin, vend, positiveOnly);
|
||||
}
|
||||
|
||||
// feed data to direct sinks
|
||||
if (sinkIndex < m_basebandSampleSinks.size())
|
||||
{
|
||||
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[sinkIndex].begin(); it != m_basebandSampleSinks[sinkIndex].end(); ++it) {
|
||||
(*it)->feed(part1begin, part1end, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// possibly feed data to spectrum sink
|
||||
if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) {
|
||||
m_spectrumSink->feed(part1begin, part1end, positiveOnly);
|
||||
}
|
||||
|
||||
// feed data to threaded sinks
|
||||
for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[sinkIndex].begin(); it != m_threadedBasebandSampleSinks[sinkIndex].end(); ++it)
|
||||
{
|
||||
(*it)->feed(part1begin, part1end, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// second part of FIFO data (used when block wraps around)
|
||||
if(part2begin != part2end)
|
||||
{
|
||||
// DC and IQ corrections
|
||||
if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) {
|
||||
iqCorrections(part2begin, part2end, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection);
|
||||
}
|
||||
|
||||
// feed data to direct sinks
|
||||
if (sinkIndex < m_basebandSampleSinks.size())
|
||||
{
|
||||
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[sinkIndex].begin(); it != m_basebandSampleSinks[sinkIndex].end(); ++it) {
|
||||
(*it)->feed(part2begin, part2end, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// possibly feed data to spectrum sink
|
||||
if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) {
|
||||
m_spectrumSink->feed(part2begin, part2end, positiveOnly);
|
||||
}
|
||||
|
||||
// feed data to threaded sinks
|
||||
for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[sinkIndex].begin(); it != m_threadedBasebandSampleSinks[sinkIndex].end(); ++it)
|
||||
{
|
||||
(*it)->feed(part2begin, part2end, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// adjust FIFO pointers
|
||||
sampleFifo->readCommit((unsigned int) count);
|
||||
samplesDone += count;
|
||||
}
|
||||
// feed data to threaded sinks
|
||||
for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[sinkIndex].begin(); it != m_threadedBasebandSampleSinks[sinkIndex].end(); ++it)
|
||||
{
|
||||
(*it)->feed(vbegin, vend, positiveOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// notStarted -> idle -> init -> running -+
|
||||
@ -583,7 +539,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
|
||||
qPrintable(mimo->getDeviceDescription()), isink);
|
||||
QObject::connect(
|
||||
m_deviceSampleMIMO->getSampleSinkFifo(isink),
|
||||
&SampleSinkFifo::dataReady,
|
||||
&SampleSinkVector::dataReady,
|
||||
this,
|
||||
[=](){ this->handleDataRxSync(); }, // lambda function is not strictly needed here
|
||||
Qt::QueuedConnection
|
||||
@ -599,7 +555,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
|
||||
qPrintable(mimo->getDeviceDescription()), isink);
|
||||
QObject::connect(
|
||||
m_deviceSampleMIMO->getSampleSinkFifo(isink),
|
||||
&SampleSinkFifo::dataReady,
|
||||
&SampleSinkVector::dataReady,
|
||||
this,
|
||||
[=](){ this->handleDataRxAsync(isink); },
|
||||
Qt::QueuedConnection
|
||||
|
@ -22,6 +22,11 @@ SampleSinkVector::SampleSinkVector(QObject* parent) :
|
||||
m_dataSize(0)
|
||||
{}
|
||||
|
||||
SampleSinkVector::SampleSinkVector(const SampleSinkVector& other) :
|
||||
m_sampleVector(other.m_sampleVector),
|
||||
m_dataSize(other.m_dataSize)
|
||||
{}
|
||||
|
||||
SampleSinkVector::~SampleSinkVector()
|
||||
{}
|
||||
|
||||
@ -38,7 +43,7 @@ void SampleSinkVector::write(const SampleVector::const_iterator& begin, const Sa
|
||||
emit dataReady();
|
||||
}
|
||||
|
||||
void SampleSinkVector::read(SampleVector::const_iterator& begin, SampleVector::const_iterator& end)
|
||||
void SampleSinkVector::read(SampleVector::iterator& begin, SampleVector::iterator& end)
|
||||
{
|
||||
begin = m_sampleVector.begin();
|
||||
end = m_sampleVector.begin() + m_dataSize;
|
||||
|
@ -28,10 +28,11 @@ class SDRBASE_API SampleSinkVector : public QObject {
|
||||
|
||||
public:
|
||||
SampleSinkVector(QObject* parent = nullptr);
|
||||
SampleSinkVector(const SampleSinkVector& other);
|
||||
~SampleSinkVector();
|
||||
|
||||
void write(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
||||
void read(SampleVector::const_iterator& begin, SampleVector::const_iterator& end);
|
||||
void read(SampleVector::iterator& begin, SampleVector::iterator& end);
|
||||
|
||||
signals:
|
||||
void dataReady();
|
||||
@ -39,9 +40,8 @@ signals:
|
||||
private:
|
||||
SampleVector m_sampleVector;
|
||||
int m_dataSize;
|
||||
int m_sampleVectorSize;
|
||||
SampleVector::const_iterator m_begin;
|
||||
SampleVector::const_iterator m_end;
|
||||
// SampleVector::const_iterator m_begin;
|
||||
// SampleVector::const_iterator m_end;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,8 +26,8 @@ void ThreadedBasebandSampleSinkFifo::writeToFifo(SampleVector::const_iterator& b
|
||||
|
||||
void ThreadedBasebandSampleSinkFifo::handleVectorData()
|
||||
{
|
||||
SampleVector::const_iterator vbegin;
|
||||
SampleVector::const_iterator vend;
|
||||
SampleVector::iterator vbegin;
|
||||
SampleVector::iterator vend;
|
||||
|
||||
if (m_sampleSink)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user