TX ph.1: Baseband sample sources and Device sample sinks (1)

pull/27/head
f4exb 2016-10-14 18:47:19 +02:00
rodzic 32aece4e4a
commit 4709ba9e01
15 zmienionych plików z 13104 dodań i 69 usunięć

Wyświetl plik

@ -118,6 +118,7 @@ set(sdrbase_SOURCES
sdrbase/dsp/samplesourcefifo.cpp
sdrbase/dsp/samplesinkfifodoublebuffered.cpp
sdrbase/dsp/basebandsamplesink.cpp
sdrbase/dsp/basebandsamplesource.cpp
sdrbase/dsp/nullsink.cpp
sdrbase/dsp/spectrumscopecombovis.cpp
sdrbase/dsp/scopevis.cpp
@ -148,6 +149,7 @@ set(sdrbase_SOURCES
sdrbase/gui/valuedial.cpp
sdrbase/dsp/devicesamplesource.cpp
sdrbase/dsp/devicesamplesink.cpp
sdrbase/plugin/pluginapi.cpp
#sdrbase/plugin/plugingui.cpp
@ -211,6 +213,7 @@ set(sdrbase_HEADERS
sdrbase/dsp/samplesinkfifodoublebuffered.h
sdrbase/dsp/samplesinkfifodecimator.h
sdrbase/dsp/basebandsamplesink.h
sdrbase/dsp/basebandsamplesource.h
sdrbase/dsp/nullsink.h
sdrbase/dsp/scopevis.h
sdrbase/dsp/spectrumvis.h
@ -241,6 +244,7 @@ set(sdrbase_HEADERS
sdrbase/gui/valuedial.h
sdrbase/dsp/devicesamplesource.h
sdrbase/dsp/devicesamplesink.h
sdrbase/plugin/pluginapi.h
sdrbase/plugin/plugingui.h

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DEVICE_DEVICESINKAPI_H_
#define SDRBASE_DEVICE_DEVICESINKAPI_H_
#include <QObject>
#include <QString>
#include "util/export.h"
class MainWindow;
class DSPDeviceSinkEngine; // TODO: TBD
class GLSpectrum;
class ChannelWindow;
class BasebandSampleSource; // TODO: TBD
class ThreadedBasebandSampleSource; // TODO: TBD
class DeviceSampleSink; // TODO: TBD
class MessageQueue;
class ChannelMarker;
class QWidget;
class PluginGUI;
class PluginAPI;
class Preset;
class SDRANGEL_API DeviceSinkAPI : public QObject {
Q_OBJECT
public:
// Device engine stuff
void addSource(BasebandSampleSource* source); //!< Add a baseband sample source to device engine
void removeSource(BasebandSampleSource* sink); //!< Remove a baseband sample source from device engine
void addThreadedSource(ThreadedBasebandSampleSource* sink); //!< Add a baseband sample source that will run on its own thread to device engine
void removeThreadedSource(ThreadedBasebandSampleSource* sink); //!< Remove a baseband sample source that runs on its own thread from device engine
void setSink(DeviceSampleSink* sink); //!< Set device engine sample sink type
bool initGeneration(); //!< Initialize device engine generation sequence
bool startGeneration(); //!< Start device engine generation sequence
void stopGeneration(); //!< Stop device engine generation sequence
//TODO: DSPDeviceSourceEngine::State state() const; //!< device engine state
QString errorMessage(); //!< Return the current device engine error message
uint getDeviceUID() const; //!< Return the current device engine unique ID
MessageQueue *getDeviceInputMessageQueue();
MessageQueue *getDeviceOutputMessageQueue();
// device related stuff
GLSpectrum *getSpectrum(); //!< Direct spectrum getter
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
ChannelWindow *getChannelWindow(); //!< Direct channel window getter
void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window
void setOutputGUI(QWidget* outputGUI, const QString& sinkDisplayName);
void setSampleSinkId(const QString& id);
void setSampleSinkSerial(const QString& serial);
void setSampleSinkSequence(int sequence);
void setSampleSinkPluginGUI(PluginGUI *gui);
void registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI);
void removeChannelInstance(PluginGUI* pluginGUI);
void freeAll();
void loadSinkSettings(const Preset* preset);
void saveSinkSettings(Preset* preset);
void loadChannelSettings(const Preset* preset, PluginAPI *pluginAPI);
void saveChannelSettings(Preset* preset);
MainWindow *getMainWindow() { return m_mainWindow; }
protected:
struct ChannelInstanceRegistration
{
QString m_channelName;
PluginGUI* m_gui;
ChannelInstanceRegistration() :
m_channelName(),
m_gui(0)
{ }
ChannelInstanceRegistration(const QString& channelName, PluginGUI* pluginGUI) :
m_channelName(channelName),
m_gui(pluginGUI)
{ }
bool operator<(const ChannelInstanceRegistration& other) const;
};
typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations;
DeviceSinkAPI(MainWindow *mainWindow,
int deviceTabIndex,
DSPDeviceSourceEngine *deviceEngine,
GLSpectrum *glSpectrum,
ChannelWindow *channelWindow);
~DeviceSinkAPI();
void renameChannelInstances();
MainWindow *m_mainWindow;
int m_deviceTabIndex;
DSPDeviceSinkEngine *m_deviceEngine;
GLSpectrum *m_spectrum;
ChannelWindow *m_channelWindow;
QString m_sampleSinkId;
QString m_sampleSinkSerial;
int m_sampleSinkSequence;
PluginGUI* m_sampleSinkPluginGUI;
ChannelInstanceRegistrations m_channelInstanceRegistrations;
friend class MainWindow;
};
#endif /* SDRBASE_DEVICE_DEVICESINKAPI_H_ */

Wyświetl plik

@ -20,7 +20,7 @@
#include <QObject>
#include <QString>
#include "../dsp/dspdevicesourceengine.h"
#include "dsp/dspdevicesourceengine.h"
#include "util/export.h"

Wyświetl plik

@ -1,3 +1,20 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_SAMPLESINK_H
#define INCLUDE_SAMPLESINK_H

Wyświetl plik

@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/basebandsamplesource.h"
#include "util/message.h"
BasebandSampleSource::BasebandSampleSource()
{
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
BasebandSampleSource::~BasebandSampleSource()
{
}
void BasebandSampleSource::handleInputMessages()
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != 0)
{
if (handleMessage(*message))
{
delete message;
}
}
}

Wyświetl plik

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_
#define SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_
#include <QObject>
#include "dsptypes.h"
#include "util/export.h"
#include "util/messagequeue.h"
class Message;
class SDRANGEL_API BasebandSampleSource : public QObject {
Q_OBJECT
public:
BasebandSampleSource();
virtual ~BasebandSampleSource();
virtual void start() = 0;
virtual void stop() = 0;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly) = 0;
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
MessageQueue *getOutputMessageQueue() { return &m_outputMessageQueue; } //!< Get the queue for asynchronous outbound communication
protected:
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
MessageQueue m_outputMessageQueue; //!< Queue for asynchronous outbound communication
protected slots:
void handleInputMessages();
};
#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */

Wyświetl plik

@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/devicesamplesink.h"
DeviceSampleSink::DeviceSampleSink() :
m_sampleSourceFifo(1<<19, 1<<16)
{
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
DeviceSampleSink::~DeviceSampleSink()
{
}
void DeviceSampleSink::handleInputMessages()
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != 0)
{
if (handleMessage(*message))
{
delete message;
}
}
}

Wyświetl plik

@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_DEVICESAMPLESINK_H_
#define SDRBASE_DSP_DEVICESAMPLESINK_H_
#include <QtGlobal>
#include "samplesourcefifo.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/export.h"
class SDRANGEL_API DeviceSampleSink : public QObject {
Q_OBJECT
public:
DeviceSampleSink();
virtual ~DeviceSampleSink();
virtual bool init(const Message& cmd) = 0;
virtual bool start(int device) = 0;
virtual void stop() = 0;
virtual const QString& getDeviceDescription() const = 0;
virtual int getSampleRate() const = 0; //!< Sample rate exposed by the sink
virtual quint64 getCenterFrequency() const = 0; //!< Center frequency exposed by the sink
virtual bool handleMessage(const Message& message) = 0;
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
MessageQueue *getOutputMessageQueueToGUI() { return &m_outputMessageQueueToGUI; }
SampleSourceFifo* getSampleFifo() { return &m_sampleSourceFifo; }
protected slots:
void handleInputMessages();
protected:
SampleSourceFifo m_sampleSourceFifo;
MessageQueue m_inputMessageQueue; //!< Input queue to the sink
MessageQueue m_outputMessageQueueToGUI; //!< Output queue specialized for the sink GUI
};
#endif /* SDRBASE_DSP_DEVICESAMPLESINK_H_ */

Wyświetl plik

@ -0,0 +1,121 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_DSPDEVICESINKENGINE_H_
#define SDRBASE_DSP_DSPDEVICESINKENGINE_H_
#include <QThread>
#include <QTimer>
#include <QMutex>
#include <QWaitCondition>
#include <list>
#include "dsp/dsptypes.h"
#include "dsp/fftwindow.h"
#include "util/messagequeue.h"
#include "util/syncmessenger.h"
#include "util/export.h"
class DeviceSampleSink;
class BasebandSampleSource;
class ThreadedBasebandSampleSource; // TODO: TBD
class SDRANGEL_API DSPDeviceSinkEngine : public QThread {
Q_OBJECT
public:
enum State {
StNotStarted, //!< engine is before initialization
StIdle, //!< engine is idle
StReady, //!< engine is ready to run
StRunning, //!< engine is running
StError //!< engine is in error
};
DSPDeviceSinkEngine(uint uid, QObject* parent = NULL);
~DSPDeviceSinkEngine();
uint getUID() const { return m_uid; }
MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
MessageQueue* getOutputMessageQueue() { return &m_outputMessageQueue; }
void start(); //!< This thread start
void stop(); //!< This thread stop
bool initGeneration(); //!< Initialize generation sequence
bool startGeneration(); //!< Start generation sequence
void stopGeneration(); //!< Stop generation sequence
void setSink(DeviceSampleSink* sink); //!< Set the sample sink type
void setSinkSequence(int sequence); //!< Set the sample sink sequence in type
void addSource(BasebandSampleSource* source); //!< Add a baseband sample source
void removeSink(BasebandSampleSource* source); //!< Remove a baseband sample source
void addThreadedSource(ThreadedBasebandSampleSource* source); //!< Add a baseband sample source that will run on its own thread
void removeThreadedSource(ThreadedBasebandSampleSource* source); //!< Remove a baseband sample source that runs on its own thread
State state() const { return m_state; } //!< Return DSP engine current state
QString errorMessage(); //!< Return the current error message
QString sinkDeviceDescription(); //!< Return the sink device description
private:
uint m_uid; //!< unique ID
MessageQueue m_inputMessageQueue; //<! Input message queue. Post here.
MessageQueue m_outputMessageQueue; //<! Output message queue. Listen here.
SyncMessenger m_syncMessenger; //!< Used to process messages synchronously with the thread
State m_state;
QString m_errorMessage;
QString m_deviceDescription;
DeviceSampleSink* m_deviceSampleSink;
int m_sampleSinkSequence;
typedef std::list<BasebandSampleSource*> BasebandSampleSources;
BasebandSampleSources m_basebandSampleSources; //!< baseband sample sources within main thread (usually file input)
typedef std::list<ThreadedBasebandSampleSource*> ThreadedBasebandSampleSources;
ThreadedBasebandSampleSources m_threadedBasebandSampleSources; //!< baseband sample sources on their own threads (usually channels)
uint m_sampleRate;
quint64 m_centerFrequency;
void run();
void work(); //!< transfer samples from beseband sources to sink if in running state
State gotoIdle(); //!< Go to the idle state
State gotoInit(); //!< Go to the acquisition init state from idle
State gotoRunning(); //!< Go to the running state from ready state
State gotoError(const QString& errorMsg); //!< Go to an error state
void handleSetSink(DeviceSampleSink* sink); //!< Manage sink setting
private slots:
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
void handleInputMessages(); //!< Handle input message queue
void handleSynchronousMessages(); //!< Handle synchronous messages with the thread
};
#endif /* SDRBASE_DSP_DSPDEVICESINKENGINE_H_ */

Wyświetl plik

@ -5,24 +5,24 @@
#include "dsp/dspcommands.h"
#include "util/message.h"
ThreadedBasebandSampleFifo::ThreadedBasebandSampleFifo(BasebandSampleSink *sampleSink, std::size_t size) :
ThreadedBasebandSampleSinkFifo::ThreadedBasebandSampleSinkFifo(BasebandSampleSink *sampleSink, std::size_t size) :
m_sampleSink(sampleSink)
{
connect(&m_sampleFifo, SIGNAL(dataReady()), this, SLOT(handleFifoData()));
m_sampleFifo.setSize(size);
}
ThreadedBasebandSampleFifo::~ThreadedBasebandSampleFifo()
ThreadedBasebandSampleSinkFifo::~ThreadedBasebandSampleSinkFifo()
{
m_sampleFifo.readCommit(m_sampleFifo.fill());
}
void ThreadedBasebandSampleFifo::writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end)
void ThreadedBasebandSampleSinkFifo::writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end)
{
m_sampleFifo.write(begin, end);
}
void ThreadedBasebandSampleFifo::handleFifoData() // FIXME: Fixed? Move it to the new threadable sink class
void ThreadedBasebandSampleSinkFifo::handleFifoData() // FIXME: Fixed? Move it to the new threadable sink class
{
bool positiveOnly = false;
@ -72,10 +72,10 @@ ThreadedBasebandSampleSink::ThreadedBasebandSampleSink(BasebandSampleSink* sampl
qDebug() << "ThreadedBasebandSampleSink::ThreadedBasebandSampleSink: " << name;
m_thread = new QThread(parent);
m_threadedBasebandSampleFifo = new ThreadedBasebandSampleFifo(m_basebandSampleSink);
m_threadedBasebandSampleSinkFifo = new ThreadedBasebandSampleSinkFifo(m_basebandSampleSink);
//moveToThread(m_thread); // FIXME: Fixed? the intermediate FIFO should be handled within the sink. Define a new type of sink that is compatible with threading
m_basebandSampleSink->moveToThread(m_thread);
m_threadedBasebandSampleFifo->moveToThread(m_thread);
m_threadedBasebandSampleSinkFifo->moveToThread(m_thread);
//m_sampleFifo.moveToThread(m_thread);
//connect(&m_sampleFifo, SIGNAL(dataReady()), this, SLOT(handleData()));
//m_sampleFifo.setSize(262144);
@ -85,7 +85,7 @@ ThreadedBasebandSampleSink::ThreadedBasebandSampleSink(BasebandSampleSink* sampl
ThreadedBasebandSampleSink::~ThreadedBasebandSampleSink()
{
delete m_threadedBasebandSampleFifo; // Valgrind memcheck
delete m_threadedBasebandSampleSinkFifo; // Valgrind memcheck
delete m_thread;
}
@ -108,7 +108,7 @@ void ThreadedBasebandSampleSink::feed(SampleVector::const_iterator begin, Sample
{
//m_sampleSink->feed(begin, end, positiveOnly);
//m_sampleFifo.write(begin, end);
m_threadedBasebandSampleFifo->writeToFifo(begin, end);
m_threadedBasebandSampleSinkFifo->writeToFifo(begin, end);
}
bool ThreadedBasebandSampleSink::handleSinkMessage(const Message& cmd)

Wyświetl plik

@ -32,12 +32,12 @@ 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
*/
class ThreadedBasebandSampleFifo : public QObject {
class ThreadedBasebandSampleSinkFifo : public QObject {
Q_OBJECT
public:
ThreadedBasebandSampleFifo(BasebandSampleSink* sampleSink, std::size_t size = 1<<18);
~ThreadedBasebandSampleFifo();
ThreadedBasebandSampleSinkFifo(BasebandSampleSink* sampleSink, std::size_t size = 1<<18);
~ThreadedBasebandSampleSinkFifo();
void writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end);
BasebandSampleSink* m_sampleSink;
@ -72,7 +72,7 @@ public:
protected:
QThread *m_thread; //!< The thead object
ThreadedBasebandSampleFifo *m_threadedBasebandSampleFifo;
ThreadedBasebandSampleSinkFifo *m_threadedBasebandSampleSinkFifo;
BasebandSampleSink* m_basebandSampleSink;
};

Wyświetl plik

@ -0,0 +1,79 @@
///////////////////////////////////////////////////////////////////////////////////
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_
#define SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_
#include <dsp/basebandsamplesource.h>
#include <QMutex>
#include "samplesourcefifo.h"
#include "util/messagequeue.h"
#include "util/export.h"
class BasebandSampleSource;
class QThread;
/**
* Because Qt is a piece of shit this class cannot be a nested protected class of ThreadedSampleSource
* So let's make everything public
*/
class ThreadedBasebandSampleSourceFifo : public QObject {
Q_OBJECT
public:
ThreadedBasebandSampleSourceFifo(BasebandSampleSource* sampleSource, std::size_t size = 1<<18);
~ThreadedBasebandSampleSourceFifo();
void writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end);
BasebandSampleSource* m_sampleSource;
SampleSourceFifo m_sampleSourceFifo;
public slots:
void handleFifoData();
};
/**
* This class is a wrapper for BasebandSampleSource that runs the BasebandSampleSource object in its own thread
*/
class SDRANGEL_API ThreadedBasebandSampleSource : public QObject {
Q_OBJECT
public:
ThreadedBasebandSampleSource(BasebandSampleSource* sampleSource, QObject *parent = 0);
~ThreadedBasebandSampleSource();
const BasebandSampleSource *getSource() const { return m_basebandSampleSource; }
MessageQueue* getInputMessageQueue() { return m_basebandSampleSource->getInputMessageQueue(); } //!< Return pointer to sample source's input message queue
MessageQueue* getOutputMessageQueue() { return m_basebandSampleSource->getOutputMessageQueue(); } //!< Return pointer to sample source's output message queue
void start(); //!< this thread start()
void stop(); //!< this thread exit() and wait()
bool handleSourceMessage(const Message& cmd); //!< Send message to source synchronously
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); //!< Feed source with samples
QString getSampleSourceObjectName() const;
protected:
QThread *m_thread; //!< The thead object
ThreadedBasebandSampleSinkFifo *m_threadedBasebandSampleSourceFifo;
BasebandSampleSource* m_basebandSampleSource;
};
#endif /* SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_ */

Wyświetl plik

@ -16,6 +16,7 @@ struct PluginDescriptor {
class PluginAPI;
class DeviceSourceAPI;
class DeviceSinkAPI;
class PluginGUI;
class QWidget;
@ -48,12 +49,16 @@ public:
// channel Rx plugins
virtual PluginGUI* createRxChannel(const QString& channelName, DeviceSourceAPI *deviceAPI) { return 0; }
// device plugins only
// channel Tx plugins
virtual PluginGUI* createTxChannel(const QString& channelName, DeviceSourceAPI *deviceAPI) { return 0; }
// device source plugins only
virtual SamplingDevices enumSampleSources() { return SamplingDevices(); }
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceSourceAPI *deviceAPI)
{
return 0;
}
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceSourceAPI *deviceAPI) { return 0; }
// device sink plugins only
virtual SamplingDevices enumSampleSinks() { return SamplingDevices(); }
virtual PluginGUI* createSampleSinkPluginGUI(const QString& sinkId, QWidget **widget, DeviceSinkAPI *deviceAPI) { return 0; }
};
Q_DECLARE_INTERFACE(PluginInterface, "SDRangel.PluginInterface/0.1");

Wyświetl plik

@ -59,6 +59,7 @@ SOURCES += mainwindow.cpp\
dsp/samplesourcefifo.cpp\
dsp/samplesinkfifodoublebuffered.cpp\
dsp/basebandsamplesink.cpp\
dsp/basebandsamplesource.cpp\
dsp/nullsink.cpp\
dsp/spectrumscopecombovis.cpp\
dsp/scopevis.cpp\
@ -87,6 +88,7 @@ SOURCES += mainwindow.cpp\
gui/scaleengine.cpp\
gui/valuedial.cpp\
dsp/devicesamplesource.cpp\
dsp/devicesamplesink.cpp\
plugin/pluginapi.cpp\
plugin/plugininterface.cpp\
plugin/pluginmanager.cpp\
@ -142,6 +144,7 @@ HEADERS += mainwindow.h\
dsp/samplesinkfifodoublebuffered.h\
dsp/samplesinkfifodecimator.h\
dsp/basebandsamplesink.h\
dsp/basebandsamplesource.h\
dsp/nullsink.h\
dsp/scopevis.h\
dsp/spectrumvis.h\
@ -170,6 +173,7 @@ HEADERS += mainwindow.h\
gui/scaleengine.h\
gui/valuedial.h\
dsp/devicesamplesource.h\
dsp/devicesamplesink.h\
plugin/pluginapi.h\
plugin/plugingui.h\
plugin/plugininterface.h\