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 //
|
|
|
|
// //
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#include <QMutex>
|
2015-08-17 02:29:34 -04:00
|
|
|
#include <QThread>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "samplesink.h"
|
|
|
|
#include "dsp/samplefifo.h"
|
|
|
|
#include "util/messagequeue.h"
|
|
|
|
#include "util/export.h"
|
2015-08-17 02:29:34 -04:00
|
|
|
#include "util/syncmessenger.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
class SampleSink;
|
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
/**
|
|
|
|
* This class is a wrapper for SampleSink that runs the SampleSink object in its own thread
|
|
|
|
*/
|
|
|
|
class SDRANGELOVE_API ThreadedSampleSink : public QThread {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ThreadedSampleSink(SampleSink* sampleSink);
|
2015-08-17 02:29:34 -04:00
|
|
|
~ThreadedSampleSink();
|
|
|
|
|
|
|
|
const SampleSink *getSink() const { return m_sampleSink; }
|
|
|
|
MessageQueue* getInputMessageQueue() { return m_sampleSink->getInputMessageQueue(); } //!< Return pointer to sample sink's input message queue
|
|
|
|
MessageQueue* getOutputMessageQueue() { return m_sampleSink->getOutputMessageQueue(); } //!< Return pointer to sample sink's output message queue
|
|
|
|
|
|
|
|
void start(); //!< this thread start()
|
|
|
|
void stop(); //!< this thread exit() and wait()
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-17 20:47:14 -04:00
|
|
|
bool sendWaitSink(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;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
protected:
|
2015-08-17 02:29:34 -04:00
|
|
|
SyncMessenger m_syncMessenger; //!< Used to process messages synchronously with the thread
|
2014-05-18 11:52:39 -04:00
|
|
|
SampleSink* m_sampleSink;
|
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
private:
|
|
|
|
void run(); //!< this thread run() method
|
2015-08-17 20:47:14 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleSynchronousMessages(); //!< Handle synchronous messages with the thread
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_THREADEDSAMPLESINK_H
|