1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Baseband sample source: change messaging mechanism between channel sink and GUI

This commit is contained in:
f4exb 2017-09-28 08:33:05 +02:00
parent ff5e233eb0
commit dda9a1dcbb
13 changed files with 106 additions and 101 deletions

View File

@ -338,7 +338,7 @@ bool AMMod::handleMessage(const Message& cmd)
MsgReportFileSourceStreamTiming *report;
report = MsgReportFileSourceStreamTiming::create(samplesCount);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
return true;
}
@ -415,7 +415,7 @@ void AMMod::openFileStream()
MsgReportFileSourceStreamData *report;
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
void AMMod::seekFileStream(int seekPercentage)

View File

@ -178,7 +178,7 @@ void AMModGUI::handleSourceMessages()
{
Message* message;
while ((message = m_amMod->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -339,6 +339,7 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pare
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_amMod = new AMMod();
m_amMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_amMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
@ -372,7 +373,7 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pare
applySettings();
connect(m_amMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_amMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
}

View File

@ -394,7 +394,7 @@ void ATVMod::pullVideo(Real& sample)
camera.m_videoWidth,
camera.m_videoHeight,
1); // open splash screen on GUI side
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
int nbFrames = 0;
time(&start);
@ -422,7 +422,7 @@ void ATVMod::pullVideo(Real& sample)
camera.m_videoWidth,
camera.m_videoHeight,
2); // close splash screen on GUI side
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
else if (camera.m_videoFPS == 0.0f) // Hideous hack for windows
{
@ -440,7 +440,7 @@ void ATVMod::pullVideo(Real& sample)
camera.m_videoWidth,
camera.m_videoHeight,
0);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
int fpsIncrement = (int) camera.m_videoFPSCount - camera.m_videoPrevFPSCount;
@ -603,7 +603,7 @@ bool ATVMod::handleMessage(const Message& cmd)
MsgReportVideoFileSourceStreamTiming *report;
report = MsgReportVideoFileSourceStreamTiming::create(framesCount);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
return true;
}
@ -624,7 +624,7 @@ bool ATVMod::handleMessage(const Message& cmd)
m_cameras[m_cameraIndex].m_videoWidth,
m_cameras[m_cameraIndex].m_videoHeight,
0);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
return true;
@ -723,7 +723,7 @@ void ATVMod::apply(bool force)
MsgReportEffectiveSampleRate *report;
report = MsgReportEffectiveSampleRate::create(m_tvSampleRate, m_pointsPerLine);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
if ((m_config.m_outputSampleRate != m_running.m_outputSampleRate)
@ -979,7 +979,7 @@ void ATVMod::openVideo(const QString& fileName)
MsgReportVideoFileSourceStreamData *report;
report = MsgReportVideoFileSourceStreamData::create(m_videoFPS, m_videoLength);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
else
{
@ -1123,7 +1123,7 @@ void ATVMod::getCameraNumbers(std::vector<int>& numbers)
m_cameras[0].m_videoWidth,
m_cameras[0].m_videoHeight,
0);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
}

View File

@ -363,7 +363,7 @@ void ATVModGUI::handleSourceMessages()
{
Message* message;
while ((message = m_atvMod->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -622,6 +622,7 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_atvMod = new ATVMod();
m_atvMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_atvMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
@ -648,7 +649,7 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
resetToDefaults();
connect(m_atvMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_atvMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
std::vector<int> cameraNumbers;

View File

@ -367,7 +367,7 @@ bool NFMMod::handleMessage(const Message& cmd)
MsgReportFileSourceStreamTiming *report;
report = MsgReportFileSourceStreamTiming::create(samplesCount);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
return true;
}
@ -462,7 +462,7 @@ void NFMMod::openFileStream()
MsgReportFileSourceStreamData *report;
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
void NFMMod::seekFileStream(int seekPercentage)

View File

@ -202,7 +202,7 @@ void NFMModGUI::handleSourceMessages()
{
Message* message;
while ((message = m_nfmMod->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -388,6 +388,7 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_nfmMod = new NFMMod();
m_nfmMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_nfmMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
@ -425,7 +426,7 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
applySettings();
connect(m_nfmMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_nfmMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
}

View File

@ -685,7 +685,7 @@ bool SSBMod::handleMessage(const Message& cmd)
MsgReportFileSourceStreamTiming *report;
report = MsgReportFileSourceStreamTiming::create(samplesCount);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
return true;
}
@ -824,7 +824,7 @@ void SSBMod::openFileStream()
MsgReportFileSourceStreamData *report;
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
void SSBMod::seekFileStream(int seekPercentage)

View File

@ -237,7 +237,7 @@ void SSBModGUI::handleSourceMessages()
{
Message* message;
while ((message = m_ssbMod->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -540,6 +540,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_ssbMod = new SSBMod(m_spectrumVis);
m_ssbMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_ssbMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
@ -580,7 +581,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
applySettings();
setNewRate(m_spanLog2);
connect(m_ssbMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_ssbMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
}

View File

@ -367,7 +367,7 @@ bool WFMMod::handleMessage(const Message& cmd)
MsgReportFileSourceStreamTiming *report;
report = MsgReportFileSourceStreamTiming::create(samplesCount);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
return true;
}
@ -463,7 +463,7 @@ void WFMMod::openFileStream()
MsgReportFileSourceStreamData *report;
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
getOutputMessageQueue()->push(report);
getMessageQueueToGUI()->push(report);
}
void WFMMod::seekFileStream(int seekPercentage)

View File

@ -183,7 +183,7 @@ void WFMModGUI::handleSourceMessages()
{
Message* message;
while ((message = m_wfmMod->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -358,6 +358,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_wfmMod = new WFMMod();
m_wfmMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_wfmMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
@ -390,7 +391,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
applySettings();
connect(m_wfmMod->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_wfmMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
}

View File

@ -178,7 +178,7 @@ void UDPSinkGUI::handleSourceMessages()
{
Message* message;
while ((message = m_udpSink->getOutputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
@ -205,6 +205,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_udpSink = new UDPSink(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_udpSink);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
@ -241,7 +242,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
displaySettings();
applySettings(true);
connect(m_udpSink->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
connect(m_udpSink, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
}

View File

@ -1,71 +1,72 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 "dsp/dsptypes.h"
#include "dsp/samplesourcefifo.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 pull(Sample& sample) = 0;
virtual void pullAudio(int nbSamples __attribute__((unused))) {}
/** direct feeding of sample source FIFO */
void feed(SampleSourceFifo* sampleFifo, int nbSamples)
{
SampleVector::iterator writeAt;
sampleFifo->getWriteIterator(writeAt);
pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly
for (int i = 0; i < nbSamples; i++)
{
pull((*writeAt));
sampleFifo->bumpIndex(writeAt);
}
}
SampleSourceFifo& getSampleSourceFifo() { return m_sampleFifo; }
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
SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing
protected slots:
void handleInputMessages();
void handleWriteToFifo(int nbSamples);
};
#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */
///////////////////////////////////////////////////////////////////////////////////
// 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 "dsp/dsptypes.h"
#include "dsp/samplesourcefifo.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 pull(Sample& sample) = 0;
virtual void pullAudio(int nbSamples __attribute__((unused))) {}
/** direct feeding of sample source FIFO */
void feed(SampleSourceFifo* sampleFifo, int nbSamples)
{
SampleVector::iterator writeAt;
sampleFifo->getWriteIterator(writeAt);
pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly
for (int i = 0; i < nbSamples; i++)
{
pull((*writeAt));
sampleFifo->bumpIndex(writeAt);
}
}
SampleSourceFifo& getSampleSourceFifo() { return m_sampleFifo; }
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
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
protected:
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI
SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing
protected slots:
void handleInputMessages();
void handleWriteToFifo(int nbSamples);
};
#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */

View File

@ -38,8 +38,6 @@ public:
~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()