2015-08-17 06:29:34 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
#ifndef INCLUDE_THREADEDSAMPLESINK_H
|
|
|
|
#define INCLUDE_THREADEDSAMPLESINK_H
|
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2014-05-18 15:52:39 +00:00
|
|
|
#include <QMutex>
|
2016-10-06 17:18:02 +00:00
|
|
|
|
|
|
|
#include "samplesinkfifo.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "util/messagequeue.h"
|
2018-03-20 12:49:21 +00:00
|
|
|
#include "export.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
class BasebandSampleSink;
|
2015-08-21 06:54:28 +00:00
|
|
|
class QThread;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-08-23 22:51:27 +00:00
|
|
|
/**
|
|
|
|
* Because Qt is a piece of shit this class cannot be a nested protected class of ThreadedSampleSink
|
|
|
|
* So let's make everything public
|
|
|
|
*/
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRBASE_API ThreadedBasebandSampleSinkFifo : public QObject {
|
2015-08-23 22:51:27 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-10-14 16:47:19 +00:00
|
|
|
ThreadedBasebandSampleSinkFifo(BasebandSampleSink* sampleSink, std::size_t size = 1<<18);
|
|
|
|
~ThreadedBasebandSampleSinkFifo();
|
2015-08-23 22:51:27 +00:00
|
|
|
void writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end);
|
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
BasebandSampleSink* m_sampleSink;
|
2016-10-06 17:18:02 +00:00
|
|
|
SampleSinkFifo m_sampleFifo;
|
2015-08-23 22:51:27 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void handleFifoData();
|
|
|
|
};
|
|
|
|
|
2015-08-17 06:29:34 +00:00
|
|
|
/**
|
|
|
|
* This class is a wrapper for SampleSink that runs the SampleSink object in its own thread
|
|
|
|
*/
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRBASE_API ThreadedBasebandSampleSink : public QObject {
|
2014-05-18 15:52:39 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-10-03 13:55:16 +00:00
|
|
|
ThreadedBasebandSampleSink(BasebandSampleSink* sampleSink, QObject *parent = 0);
|
|
|
|
~ThreadedBasebandSampleSink();
|
2015-08-17 06:29:34 +00:00
|
|
|
|
2016-10-03 23:49:28 +00:00
|
|
|
const BasebandSampleSink *getSink() const { return m_basebandSampleSink; }
|
2015-08-17 06:29:34 +00:00
|
|
|
|
|
|
|
void start(); //!< this thread start()
|
|
|
|
void stop(); //!< this thread exit() and wait()
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-12-10 00:56:38 +00:00
|
|
|
bool handleSinkMessage(const Message& cmd); //!< Send message to sink synchronously
|
2015-08-20 01:38:31 +00:00
|
|
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); //!< Feed sink with samples
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2015-08-17 06:29:34 +00:00
|
|
|
QString getSampleSinkObjectName() const;
|
2018-03-06 01:23:47 +00:00
|
|
|
const QThread *getThread() const { return m_thread; }
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
protected:
|
2015-08-23 22:51:27 +00:00
|
|
|
|
2015-08-21 06:54:28 +00:00
|
|
|
QThread *m_thread; //!< The thead object
|
2016-10-14 16:47:19 +00:00
|
|
|
ThreadedBasebandSampleSinkFifo *m_threadedBasebandSampleSinkFifo;
|
2016-10-03 23:49:28 +00:00
|
|
|
BasebandSampleSink* m_basebandSampleSink;
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_THREADEDSAMPLESINK_H
|