1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-30 03:38:55 -05:00
sdrangel/sdrbase/dsp/threadedbasebandsamplesink.h

80 lines
3.2 KiB
C
Raw Normal View History

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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_THREADEDSAMPLESINK_H
#define INCLUDE_THREADEDSAMPLESINK_H
#include <dsp/basebandsamplesink.h>
#include <QMutex>
#include "samplesinkfifo.h"
#include "util/messagequeue.h"
#include "export.h"
class BasebandSampleSink;
class QThread;
/**
* 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 {
Q_OBJECT
public:
ThreadedBasebandSampleSinkFifo(BasebandSampleSink* sampleSink, std::size_t size = 1<<18);
~ThreadedBasebandSampleSinkFifo();
void writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end);
BasebandSampleSink* m_sampleSink;
SampleSinkFifo m_sampleFifo;
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 {
Q_OBJECT
public:
ThreadedBasebandSampleSink(BasebandSampleSink* sampleSink, QObject *parent = 0);
~ThreadedBasebandSampleSink();
2015-08-17 02:29:34 -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()
bool handleSinkMessage(const Message& cmd); //!< Send message to sink synchronously
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); //!< Feed sink with samples
2015-08-17 02:29:34 -04:00
QString getSampleSinkObjectName() const;
const QThread *getThread() const { return m_thread; }
protected:
QThread *m_thread; //!< The thead object
ThreadedBasebandSampleSinkFifo *m_threadedBasebandSampleSinkFifo;
BasebandSampleSink* m_basebandSampleSink;
};
#endif // INCLUDE_THREADEDSAMPLESINK_H