Browse Source

MIMO engine: use SampleSinkVectors instead of SampleSinkFIFOs

chirpmodem-v8.0.0
f4exb 7 years ago
parent
commit
6dae67d5b1
  1. 3
      plugins/samplemimo/testmi/testmi.cpp
  2. 2
      plugins/samplemimo/testmi/testmithread.cpp
  3. 6
      plugins/samplemimo/testmi/testmithread.h
  4. 2
      sdrbase/dsp/devicesamplemimo.cpp
  5. 6
      sdrbase/dsp/devicesamplemimo.h
  6. 96
      sdrbase/dsp/dspdevicemimoengine.cpp
  7. 7
      sdrbase/dsp/samplesinkvector.cpp
  8. 8
      sdrbase/dsp/samplesinkvector.h
  9. 4
      sdrbase/dsp/threadedbasebandsamplesink.cpp

3
plugins/samplemimo/testmi/testmi.cpp

@ -50,8 +50,7 @@ TestMI::TestMI(DeviceAPI *deviceAPI) : @@ -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*)));

2
plugins/samplemimo/testmi/testmithread.cpp

@ -28,7 +28,7 @@ @@ -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),

6
plugins/samplemimo/testmi/testmithread.h

@ -25,7 +25,7 @@ @@ -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: @@ -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: @@ -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;

2
sdrbase/dsp/devicesamplemimo.cpp

@ -52,7 +52,7 @@ SampleSourceFifo* DeviceSampleMIMO::getSampleSourceFifo(unsigned int index) @@ -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;

6
sdrbase/dsp/devicesamplemimo.h

@ -22,7 +22,7 @@ @@ -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: @@ -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: @@ -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
};

96
sdrbase/dsp/dspdevicemimoengine.cpp

@ -254,79 +254,35 @@ QString DSPDeviceMIMOEngine::deviceDescription() @@ -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;
std::size_t count = sampleFifo->readBegin(sampleFifo->fill(), &part1begin, &part1end, &part2begin, &part2end);
// 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);
}
// 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);
}
}
// DC and IQ corrections
if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) {
iqCorrections(vbegin, vend, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection);
}
// possibly feed data to spectrum sink
if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) {
m_spectrumSink->feed(part2begin, part2end, 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(vbegin, vend, 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);
}
}
// possibly feed data to spectrum sink
if ((m_spectrumSink) && (m_spectrumInputSourceElseSink) && (sinkIndex == m_spectrumInputIndex)) {
m_spectrumSink->feed(vbegin, vend, 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) @@ -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) @@ -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

7
sdrbase/dsp/samplesinkvector.cpp

@ -22,6 +22,11 @@ SampleSinkVector::SampleSinkVector(QObject* parent) : @@ -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 @@ -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;

8
sdrbase/dsp/samplesinkvector.h

@ -28,10 +28,11 @@ class SDRBASE_API SampleSinkVector : public QObject { @@ -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: @@ -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;
};

4
sdrbase/dsp/threadedbasebandsamplesink.cpp

@ -26,8 +26,8 @@ void ThreadedBasebandSampleSinkFifo::writeToFifo(SampleVector::const_iterator& b @@ -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…
Cancel
Save