diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputthread.h b/plugins/samplesink/hackrfoutput/hackrfoutputthread.h index add7eef80..9bad736fd 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputthread.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputthread.h @@ -23,7 +23,6 @@ #include #include -#include "dsp/samplesourcefifodb.h" #include "dsp/interpolators.h" #define HACKRF_BLOCKSIZE (1<<17) diff --git a/sdrbase/dsp/basebandsamplesource.h b/sdrbase/dsp/basebandsamplesource.h index 0d4fb8206..28ea5f7bb 100644 --- a/sdrbase/dsp/basebandsamplesource.h +++ b/sdrbase/dsp/basebandsamplesource.h @@ -21,7 +21,6 @@ #include #include "dsp/dsptypes.h" -#include "dsp/samplesourcefifodb.h" #include "export.h" #include "util/messagequeue.h" diff --git a/sdrbase/dsp/devicesamplemimo.h b/sdrbase/dsp/devicesamplemimo.h index 260d93f63..c68194aa3 100644 --- a/sdrbase/dsp/devicesamplemimo.h +++ b/sdrbase/dsp/devicesamplemimo.h @@ -21,7 +21,6 @@ #include -#include "samplesourcefifodb.h" #include "samplemififo.h" #include "samplemofifo.h" #include "util/message.h" @@ -173,4 +172,4 @@ protected: MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI }; -#endif // SDRBASE_DSP_DEVICESAMPLEMIMO_H_ \ No newline at end of file +#endif // SDRBASE_DSP_DEVICESAMPLEMIMO_H_ diff --git a/sdrbase/dsp/dspdevicesinkengine.cpp b/sdrbase/dsp/dspdevicesinkengine.cpp index edac8e5fc..dce53868f 100644 --- a/sdrbase/dsp/dspdevicesinkengine.cpp +++ b/sdrbase/dsp/dspdevicesinkengine.cpp @@ -26,7 +26,6 @@ #include "dsp/basebandsamplesink.h" #include "dsp/devicesamplesink.h" #include "dsp/dspcommands.h" -#include "samplesourcefifodb.h" DSPDeviceSinkEngine::DSPDeviceSinkEngine(uint32_t uid, QObject* parent) : QThread(parent), diff --git a/sdrbase/dsp/samplesourcefifodb.cpp b/sdrbase/dsp/samplesourcefifodb.cpp deleted file mode 100644 index d39e5be63..000000000 --- a/sdrbase/dsp/samplesourcefifodb.cpp +++ /dev/null @@ -1,122 +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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include "samplesourcefifodb.h" - -SampleSourceFifoDB::SampleSourceFifoDB(uint32_t size, QObject* parent) : - QObject(parent), - m_size(size), - m_init(false) -{ - m_data.resize(2*m_size); - init(); -} - -SampleSourceFifoDB::SampleSourceFifoDB(const SampleSourceFifoDB& other) : - QObject(other.parent()), - m_size(other.m_size), - m_data(other.m_data) -{ - init(); -} - -SampleSourceFifoDB::~SampleSourceFifoDB() -{} - -void SampleSourceFifoDB::resize(uint32_t size) -{ - qDebug("SampleSourceFifoDB::resize: %d", size); - - m_size = size; - m_data.resize(2*m_size); - init(); -} - -void SampleSourceFifoDB::init() -{ - static Sample zero = {0,0}; - std::fill(m_data.begin(), m_data.end(), zero); - m_ir = 0; - m_iw = m_size/2; - m_init = true; -} - -void SampleSourceFifoDB::readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples) -{ -// QMutexLocker mutexLocker(&m_mutex); - nbSamples = nbSamples > m_size/2 ? m_size/2 : nbSamples; - emit dataWrite(nbSamples); - - m_ir = (m_ir + nbSamples) % m_size; - readUntil = m_data.begin() + m_size + m_ir; - emit dataRead(nbSamples); -} - -void SampleSourceFifoDB::readAdvance(SampleVector::const_iterator& readUntil, unsigned int nbSamples) -{ -// QMutexLocker mutexLocker(&m_mutex); - nbSamples = nbSamples > m_size/2 ? m_size/2 : nbSamples; - emit dataWrite(nbSamples); - - m_ir = (m_ir + nbSamples) % m_size; - readUntil = m_data.begin() + m_size + m_ir; - emit dataRead(nbSamples); -} - -void SampleSourceFifoDB::write(const Sample& sample) -{ - m_data[m_iw] = sample; - m_data[m_iw+m_size] = sample; - - { -// QMutexLocker mutexLocker(&m_mutex); - m_iw = (m_iw+1) % m_size; - } -} - -void SampleSourceFifoDB::getReadIterator(SampleVector::iterator& readUntil) -{ - readUntil = m_data.begin() + m_size + m_ir; -} - -void SampleSourceFifoDB::getWriteIterator(SampleVector::iterator& writeAt) -{ - writeAt = m_data.begin() + m_iw; -} - -void SampleSourceFifoDB::bumpIndex(SampleVector::iterator& writeAt) -{ - m_data[m_iw+m_size] = m_data[m_iw]; - - { -// QMutexLocker mutexLocker(&m_mutex); - m_iw = (m_iw+1) % m_size; - } - - writeAt = m_data.begin() + m_iw; -} - -int SampleSourceFifoDB::getIteratorOffset(const SampleVector::iterator& iterator) -{ - return iterator - m_data.begin(); -} - -void SampleSourceFifoDB::setIteratorFromOffset(SampleVector::iterator& iterator, int offset) -{ - iterator = m_data.begin() + offset; -} diff --git a/sdrbase/dsp/samplesourcefifodb.h b/sdrbase/dsp/samplesourcefifodb.h deleted file mode 100644 index a9b7bbbe2..000000000 --- a/sdrbase/dsp/samplesourcefifodb.h +++ /dev/null @@ -1,75 +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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_DSP_SAMPLESOURCEFIFODB_H_ -#define SDRBASE_DSP_SAMPLESOURCEFIFODB_H_ - -#include -#include -#include -#include "export.h" -#include "dsp/dsptypes.h" - -class SDRBASE_API SampleSourceFifoDB : public QObject { - Q_OBJECT - -public: - SampleSourceFifoDB(uint32_t size, QObject* parent = nullptr); - SampleSourceFifoDB(const SampleSourceFifoDB& other); - ~SampleSourceFifoDB(); - - void resize(uint32_t size); - uint32_t size() const { return m_size; } - void init(); - /** advance read pointer for the given length and activate R/W signals */ - void readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples); - void readAdvance(SampleVector::const_iterator& readUntil, unsigned int nbSamples); - - void getReadIterator(SampleVector::iterator& readUntil); //!< get iterator past the last sample of a read advance operation (i.e. current read iterator) - void getWriteIterator(SampleVector::iterator& writeAt); //!< get iterator to current item for update - write phase 1 - void bumpIndex(SampleVector::iterator& writeAt); //!< copy current item to second buffer and bump write index - write phase 2 - int getIteratorOffset(const SampleVector::iterator& iterator); - void setIteratorFromOffset(SampleVector::iterator& iterator, int offset); - - void write(const Sample& sample); //!< write directly - phase 1 + phase 2 - - /** returns ratio of off center over buffer size with sign: negative read lags and positive read leads */ - float getRWBalance() const - { - int delta; - if (m_iw > m_ir) { - delta = (m_size/2) - (m_iw - m_ir); - } else { - delta = (m_ir - m_iw) - (m_size/2); - } - return delta / (float) m_size; - } - -private: - uint32_t m_size; - SampleVector m_data; - uint32_t m_iw; - uint32_t m_ir; - bool m_init; - QMutex m_mutex; - -signals: - void dataWrite(int nbSamples); // signal data is read past a threshold and writing new samples to fill in is needed - void dataRead(int nbSamples); // signal a read has been done for a number of samples -}; - -#endif /* SDRBASE_DSP_SAMPLESOURCEFIFO_H_ */