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