2014-05-18 11:52:39 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
2023-11-19 00:43:20 -05:00
|
|
|
// Copyright (C) 2015-2016, 2018-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2022 Jiří Pinkava <jiri.pinkava@rossum.ai> //
|
2014-05-18 11:52:39 -04:00
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 08:32:15 -04:00
|
|
|
// (at your option) any later version. //
|
2014-05-18 11:52:39 -04:00
|
|
|
// //
|
|
|
|
// 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 INCLUDE_SAMPLEFIFO_H
|
|
|
|
#define INCLUDE_SAMPLEFIFO_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2022-09-15 15:59:42 -04:00
|
|
|
#include <QRecursiveMutex>
|
2020-04-19 00:13:32 -04:00
|
|
|
#include <QElapsedTimer>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "dsp/dsptypes.h"
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRBASE_API SampleSinkFifo : public QObject {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
2020-04-19 00:13:32 -04:00
|
|
|
QElapsedTimer m_msgRateTimer;
|
2014-05-18 11:52:39 -04:00
|
|
|
int m_suppressed;
|
|
|
|
SampleVector m_data;
|
2022-03-15 17:21:06 -04:00
|
|
|
int m_total;
|
|
|
|
unsigned int m_writtenSignalCount;
|
|
|
|
unsigned int m_writtenSignalRateDivider;
|
2022-09-15 15:59:42 -04:00
|
|
|
QRecursiveMutex m_mutex;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2019-10-03 02:36:38 -04:00
|
|
|
unsigned int m_size;
|
|
|
|
unsigned int m_fill;
|
|
|
|
unsigned int m_head;
|
|
|
|
unsigned int m_tail;
|
2022-03-17 16:10:30 -04:00
|
|
|
QString m_label;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2019-10-03 02:36:38 -04:00
|
|
|
void create(unsigned int s);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
public:
|
2019-05-18 00:30:37 -04:00
|
|
|
SampleSinkFifo(QObject* parent = nullptr);
|
|
|
|
SampleSinkFifo(int size, QObject* parent = nullptr);
|
|
|
|
SampleSinkFifo(const SampleSinkFifo& other);
|
2016-10-06 13:18:02 -04:00
|
|
|
~SampleSinkFifo();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
bool setSize(int size);
|
2019-11-23 01:39:57 -05:00
|
|
|
void reset();
|
2022-03-15 17:21:06 -04:00
|
|
|
void setWrittenSignalRateDivider(unsigned int divider);
|
2021-04-26 13:33:02 -04:00
|
|
|
inline unsigned int size() { QMutexLocker mutexLocker(&m_mutex); unsigned int size = m_size; return size; }
|
2019-10-03 02:36:38 -04:00
|
|
|
inline unsigned int fill() { QMutexLocker mutexLocker(&m_mutex); unsigned int fill = m_fill; return fill; }
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2019-10-03 02:36:38 -04:00
|
|
|
unsigned int write(const quint8* data, unsigned int count);
|
|
|
|
unsigned int write(SampleVector::const_iterator begin, SampleVector::const_iterator end);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2019-10-03 02:36:38 -04:00
|
|
|
unsigned int read(SampleVector::iterator begin, SampleVector::iterator end);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2019-10-03 02:36:38 -04:00
|
|
|
unsigned int readBegin(unsigned int count,
|
2014-05-18 11:52:39 -04:00
|
|
|
SampleVector::iterator* part1Begin, SampleVector::iterator* part1End,
|
|
|
|
SampleVector::iterator* part2Begin, SampleVector::iterator* part2End);
|
2019-10-03 02:36:38 -04:00
|
|
|
unsigned int readCommit(unsigned int count);
|
2022-03-17 16:10:30 -04:00
|
|
|
void setLabel(const QString& label) { m_label = label; }
|
2019-11-23 01:39:57 -05:00
|
|
|
static unsigned int getSizePolicy(unsigned int sampleRate);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void dataReady();
|
2022-03-15 17:21:06 -04:00
|
|
|
void written(int nsamples, qint64 timestamp);
|
|
|
|
void overflow(int nsamples);
|
|
|
|
void underflow(int nsamples);
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SAMPLEFIFO_H
|