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