1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Fallback of sample sink vector in test MI source and device MIMO engine

This commit is contained in:
f4exb 2019-09-10 18:44:43 +02:00
parent 7a1fa085c5
commit 0a03c5d587
7 changed files with 78 additions and 21 deletions

View File

@ -50,7 +50,9 @@ TestMI::TestMI(DeviceAPI *deviceAPI) :
m_masterTimer(deviceAPI->getMasterTimer())
{
m_mimoType = MIMOAsynchronous;
m_sampleSinkFifos.resize(2);
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
m_sampleSinkFifos.push_back(SampleSinkFifo(96000 * 4));
//m_sampleSinkVectors.resize(2);
m_deviceAPI->setNbSourceStreams(2);
m_networkManager = new QNetworkAccessManager();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));

View File

@ -28,7 +28,7 @@
MESSAGE_CLASS_DEFINITION(TestMIThread::MsgStartStop, Message)
TestMIThread::TestMIThread(SampleSinkVector* sampleFifo, int streamIndex, QObject* parent) :
TestMIThread::TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent) :
QThread(parent),
m_running(false),
m_buf(0),

View File

@ -25,7 +25,6 @@
#include <QElapsedTimer>
#include <QDebug>
#include "dsp/samplesinkvector.h"
#include "dsp/decimators.h"
#include "dsp/ncof.h"
#include "util/message.h"
@ -35,6 +34,8 @@
#define TESTMI_THROTTLE_MS 50
class SampleSinkFifo;
class TestMIThread : public QThread {
Q_OBJECT
@ -58,7 +59,7 @@ public:
{ }
};
TestMIThread(SampleSinkVector* sampleFifo, int streamIndex, QObject* parent = 0);
TestMIThread(SampleSinkFifo* sampleFifo, int streamIndex, QObject* parent = 0);
~TestMIThread();
void startStop(bool start);
@ -89,7 +90,7 @@ private:
quint32 m_bufsize;
quint32 m_chunksize;
SampleVector m_convertBuffer;
SampleSinkVector* m_sampleFifo;
SampleSinkFifo* m_sampleFifo;
int m_streamIndex;
NCOF m_nco;
NCOF m_toneNco;

View File

@ -52,7 +52,7 @@ SampleSourceFifo* DeviceSampleMIMO::getSampleSourceFifo(unsigned int index)
}
}
SampleSinkVector* DeviceSampleMIMO::getSampleSinkFifo(unsigned int index)
SampleSinkFifo* DeviceSampleMIMO::getSampleSinkFifo(unsigned int index)
{
if (index >= m_sampleSinkFifos.size()) {
return nullptr;
@ -60,3 +60,12 @@ SampleSinkVector* DeviceSampleMIMO::getSampleSinkFifo(unsigned int index)
return &m_sampleSinkFifos[index];
}
}
SampleSinkVector* DeviceSampleMIMO::getSampleSinkVector(unsigned int index)
{
if (index >= m_sampleSinkVectors.size()) {
return nullptr;
} else {
return &m_sampleSinkVectors[index];
}
}

View File

@ -22,6 +22,7 @@
#include <vector>
#include "samplesourcefifo.h"
#include "samplesinkfifo.h"
#include "samplesinkvector.h"
#include "util/message.h"
#include "util/messagequeue.h"
@ -133,7 +134,8 @@ 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
SampleSinkVector* getSampleSinkFifo(unsigned int index); //!< Get Rx FIFO at index
SampleSinkFifo* getSampleSinkFifo(unsigned int index); //!< Get Rx FIFO at index
SampleSinkVector* getSampleSinkVector(unsigned int index); //!< Get Rx vector buffer at index (TODO: remove if not used)
// 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 +148,8 @@ protected slots:
protected:
MIMOType m_mimoType;
std::vector<SampleSourceFifo> m_sampleSourceFifos; //!< Tx FIFOs
std::vector<SampleSinkVector> m_sampleSinkFifos; //!< Rx FIFOs
std::vector<SampleSinkFifo> m_sampleSinkFifos; //!< Rx FIFOs
std::vector<SampleSinkVector> m_sampleSinkVectors; //!< Rx vector buffer (TODO: remove if not used)
MessageQueue m_inputMessageQueue; //!< Input queue to the sink
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI
};

View File

@ -267,18 +267,59 @@ QString DSPDeviceMIMOEngine::deviceDescription()
return cmd.getDeviceDescription();
}
void DSPDeviceMIMOEngine::workSampleSinkVector(unsigned int sinkIndex)
{
SampleSinkVector* sampleFifo = m_deviceSampleMIMO->getSampleSinkVector(sinkIndex);
if (!sampleFifo) {
return;
}
SampleVector::iterator vbegin;
SampleVector::iterator vend;
sampleFifo->read(vbegin, vend);
workSamplePart(vbegin, vend, sinkIndex);
}
void DSPDeviceMIMOEngine::workSampleSinkFifo(unsigned int sinkIndex)
{
SampleSinkFifo* sampleFifo = m_deviceSampleMIMO->getSampleSinkFifo(sinkIndex);
int samplesDone = 0;
if (!sampleFifo) {
return;
}
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);
if (part1begin != part1end) { // first part of FIFO data
workSamplePart(part1begin, part1end, sinkIndex);
}
if (part2begin != part2end) { // second part of FIFO data (used when block wraps around)
workSamplePart(part1begin, part1end, sinkIndex);
}
sampleFifo->readCommit((unsigned int) count); // adjust FIFO pointers
samplesDone += count;
}
}
/**
* Routes samples from device source FIFO to sink channels that are registered for the FIFO
* Routes samples from source channels registered for the FIFO to the device sink FIFO
*/
void DSPDeviceMIMOEngine::workSampleSink(unsigned int sinkIndex)
void DSPDeviceMIMOEngine::workSamplePart(const SampleVector::iterator& vbegin, const SampleVector::iterator& vend, unsigned int sinkIndex)
{
SampleSinkVector* sampleFifo = m_deviceSampleMIMO->getSampleSinkFifo(sinkIndex);
SampleVector::iterator vbegin;
SampleVector::iterator vend;
bool positiveOnly = false;
sampleFifo->read(vbegin, vend);
// DC and IQ corrections
if (m_sourcesCorrections[sinkIndex].m_dcOffsetCorrection) {
iqCorrections(vbegin, vend, sinkIndex, m_sourcesCorrections[sinkIndex].m_iqImbalanceCorrection);
@ -558,9 +599,8 @@ void DSPDeviceMIMOEngine::handleDataRxSync()
{
if (m_state == StRunning)
{
// Sources (move their samples into sinks)
for (unsigned int isource = 0; isource < m_deviceSampleMIMO->getNbSourceStreams(); isource++) {
workSampleSink(isource);
for (unsigned int isink = 0; isink < m_deviceSampleMIMO->getNbSinkFifos(); isink++) {
workSampleSinkFifo(isink);
}
}
}
@ -568,7 +608,7 @@ void DSPDeviceMIMOEngine::handleDataRxSync()
void DSPDeviceMIMOEngine::handleDataRxAsync(unsigned int sinkIndex)
{
if (m_state == StRunning) {
workSampleSink(sinkIndex);
workSampleSinkFifo(sinkIndex);
}
}
@ -601,7 +641,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
qPrintable(mimo->getDeviceDescription()), isink);
QObject::connect(
m_deviceSampleMIMO->getSampleSinkFifo(isink),
&SampleSinkVector::dataReady,
&SampleSinkFifo::dataReady,
this,
[=](){ this->handleDataRxSync(); }, // lambda function is not strictly needed here
Qt::QueuedConnection
@ -617,7 +657,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
qPrintable(mimo->getDeviceDescription()), isink);
QObject::connect(
m_deviceSampleMIMO->getSampleSinkFifo(isink),
&SampleSinkVector::dataReady,
&SampleSinkFifo::dataReady,
this,
[=](){ this->handleDataRxAsync(isink); },
Qt::QueuedConnection

View File

@ -379,7 +379,9 @@ private:
unsigned int m_spectrumInputIndex; //!< Index of the stream to be used as spectrum sink input
void run();
void workSampleSink(unsigned int sinkIndex); //!< transfer samples of one sink (asynchronously)
void workSampleSinkFifo(unsigned int sinkIndex); //!< transfer samples of one sink (asynchronously)
void workSampleSinkVector(unsigned int sinkIndex); //!< same but sample sink vector flavor (TODO: remove if unused)
void workSamplePart(const SampleVector::iterator& vbegin, const SampleVector::iterator& vend, unsigned int sinkIndex);
State gotoIdle(); //!< Go to the idle state
State gotoInit(); //!< Go to the acquisition init state from idle