1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-02-03 09:44:01 -05:00

Sample sinks cleanup

This commit is contained in:
f4exb 2019-10-16 19:36:13 +02:00
parent b18d81e16b
commit f1b69327c1
8 changed files with 2 additions and 1660 deletions

View File

@ -99,9 +99,7 @@ set(sdrbase_SOURCES
dsp/projector.cpp
dsp/samplemififo.cpp
dsp/samplesinkfifo.cpp
dsp/samplesinkvector.cpp
dsp/samplesourcefifo.cpp
dsp/samplesinkfifodoublebuffered.cpp
dsp/basebandsamplesink.cpp
dsp/basebandsamplesource.cpp
dsp/nullsink.cpp
@ -239,10 +237,7 @@ set(sdrbase_HEADERS
dsp/recursivefilters.h
dsp/samplemififo.h
dsp/samplesinkfifo.h
dsp/samplesinkvector.h
dsp/samplesourcefifo.h
dsp/samplesinkfifodoublebuffered.h
dsp/samplesinkfifodecimator.h
dsp/basebandsamplesink.h
dsp/basebandsamplesource.h
dsp/nullsink.h

View File

@ -268,26 +268,6 @@ void DSPDeviceMIMOEngine::workSampleSinkFifos()
workSamples(data[stream].begin() + iPart2Begin, data[stream].begin() + iPart2End, stream);
}
}
// for (unsigned int stream = 0; stream < data.size(); stream++)
// {
// SampleVector::const_iterator begin = data[stream].begin();
// if (iPart1Begin != iPart1End) {
// m_vectorBuffer.write(data[stream].begin() + iPart1Begin, data[stream].begin() + iPart1End, false);
// }
// if (iPart2Begin != iPart2End) {
// m_vectorBuffer.write(data[stream].begin() + iPart2Begin, data[stream].begin() + iPart2End, false);
// }
// SampleVector::iterator vbegin, vend;
// m_vectorBuffer.read(vbegin, vend);
// workSamples(vbegin, vend, stream);
// }
//sampleFifo->readCommitSync(count);
//samplesDone += count;
}
}
@ -310,18 +290,12 @@ void DSPDeviceMIMOEngine::workSampleSinkFifo(unsigned int stream)
sampleFifo->readAsync(&part1begin, &part1end, &part2begin, &part2end, stream);
if (part1begin != part1end) { // first part of FIFO data
m_vectorBuffer.write(part1begin, part1end, false);
workSamples(part1begin, part1end, stream);
}
if (part2begin != part2end) { // second part of FIFO data (used when block wraps around)
m_vectorBuffer.append(part2begin, part2end);
workSamples(part2begin, part2end, stream);
}
SampleVector::iterator vbegin, vend;
m_vectorBuffer.read(vbegin, vend);
workSamples(vbegin, vend, stream);
//sampleFifo->readCommitAsync(count, stream);
}
}

View File

@ -22,7 +22,6 @@
#include <QThread>
#include "dsp/dsptypes.h"
#include "dsp/samplesinkvector.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/syncmessenger.h"
@ -357,7 +356,6 @@ private:
BasebandSampleSink *m_spectrumSink; //!< The spectrum sink
bool m_spectrumInputSourceElseSink; //!< Source else sink stream to be used as spectrum sink input
unsigned int m_spectrumInputIndex; //!< Index of the stream to be used as spectrum sink input
SampleSinkVector m_vectorBuffer;
void run();
void workSampleSinkFifos(); //!< transfer samples of all sinks (sync mode)

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "samplesinkfifodoublebuffered.h"
SampleSinkFifoDoubleBuffered::SampleSinkFifoDoubleBuffered(uint32_t size, uint32_t signalThreshold) :
m_size(size),
m_signalThreshold(signalThreshold),
m_i(0),
m_count(0),
m_readIndex(0),
m_readCount(0)
{
assert(m_signalThreshold < m_size/2);
m_data.resize(2*m_size);
}
SampleSinkFifoDoubleBuffered::~SampleSinkFifoDoubleBuffered()
{
}
void SampleSinkFifoDoubleBuffered::getWriteIterator(SampleVector::iterator& it1)
{
it1 = m_data.begin() + m_i;
}
void SampleSinkFifoDoubleBuffered::bumpIndex(SampleVector::iterator& it1)
{
m_data[m_i+m_size] = m_data[m_i];
m_i = (m_i+1) % m_size;
it1 = m_data.begin() + m_i;
if (m_count < m_signalThreshold)
{
m_count++;
}
else
{
QMutexLocker mutexLocker(&m_mutex);
m_readIndex = m_i + m_size - m_count;
m_readCount = m_count;
m_count = 0;
emit dataReady();
}
}
void SampleSinkFifoDoubleBuffered::read(SampleVector::iterator& begin, SampleVector::iterator& end)
{
QMutexLocker mutexLocker(&m_mutex);
begin = m_data.begin() + m_readIndex;
end = begin + m_readCount;
}

View File

@ -1,53 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_
#define SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_
#include <QObject>
#include <QMutex>
#include <stdint.h>
#include <assert.h>
#include "export.h"
#include "dsp/dsptypes.h"
class SDRBASE_API SampleSinkFifoDoubleBuffered : public QObject {
Q_OBJECT
public:
SampleSinkFifoDoubleBuffered(uint32_t size, uint32_t signalThreshold);
~SampleSinkFifoDoubleBuffered();
void getWriteIterator(SampleVector::iterator& it1);
void bumpIndex(SampleVector::iterator& it1);
void read(SampleVector::iterator& begin, SampleVector::iterator& end);
private:
uint32_t m_size;
uint32_t m_signalThreshold;
SampleVector m_data;
uint32_t m_i;
uint32_t m_count;
uint32_t m_readIndex;
uint32_t m_readCount;
QMutex m_mutex;
signals:
void dataReady();
};
#endif /* SDRBASE_DSP_SAMPLESINKFIFODOUBLEBUFFERED_H_ */

View File

@ -1,67 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "samplesinkvector.h"
SampleSinkVector::SampleSinkVector(QObject* parent) :
QObject(parent),
m_dataSize(0)
{}
SampleSinkVector::SampleSinkVector(const SampleSinkVector& other) :
m_sampleVector(other.m_sampleVector),
m_dataSize(other.m_dataSize)
{}
SampleSinkVector::~SampleSinkVector()
{}
void SampleSinkVector::write(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal)
{
if (end - begin > m_sampleVector.size()) {
m_sampleVector.resize(end - begin);
}
std::copy(begin, end, m_sampleVector.begin());
m_dataSize = end - begin;
// m_begin = begin;
// m_end = end;
if (signal) {
emit dataReady();
}
}
void SampleSinkVector::append(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal)
{
if ((end - begin) + m_dataSize > m_sampleVector.size()) {
m_sampleVector.resize((end - begin) + m_dataSize);
}
std::copy(begin, end, m_sampleVector.begin() + m_dataSize);
m_dataSize += (end - begin);
if (signal) {
emit dataReady();
}
}
void SampleSinkVector::read(SampleVector::iterator& begin, SampleVector::iterator& end)
{
begin = m_sampleVector.begin();
end = m_sampleVector.begin() + m_dataSize;
// begin = m_begin;
// end = m_end;
}

View File

@ -1,49 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_SAMPLESINKVECTOR_H_
#define SDRBASE_DSP_SAMPLESINKVECTOR_H_
#include <QObject>
#include "dsp/dsptypes.h"
#include "export.h"
class SDRBASE_API SampleSinkVector : public QObject {
Q_OBJECT
public:
SampleSinkVector(QObject* parent = nullptr);
SampleSinkVector(const SampleSinkVector& other);
~SampleSinkVector();
void write(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal = true);
void append(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool signal = false);
void read(SampleVector::iterator& begin, SampleVector::iterator& end);
signals:
void dataReady();
private:
SampleVector m_sampleVector;
int m_dataSize;
// SampleVector::const_iterator m_begin;
// SampleVector::const_iterator m_end;
};
#endif // SDRBASE_DSP_SAMPLESINKVECTOR_H_