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

ChannelAPI rework: make handleMessage method protected

This commit is contained in:
f4exb 2022-02-12 21:41:20 +01:00
parent 02ec2a4403
commit 41061de50b
9 changed files with 61 additions and 40 deletions

View File

@ -28,6 +28,11 @@ BasebandSampleSink::~BasebandSampleSink()
{
}
void BasebandSampleSink::pushMessage(Message *msg)
{
m_inputMessageQueue.push(msg);
}
void BasebandSampleSink::handleInputMessages()
{
Message* message;

View File

@ -35,7 +35,7 @@ public:
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
void pushMessage(Message *msg);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
@ -46,6 +46,7 @@ public:
}
protected:
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
protected slots:

View File

@ -28,6 +28,11 @@ BasebandSampleSource::~BasebandSampleSource()
{
}
void BasebandSampleSource::pushMessage(Message *msg)
{
m_inputMessageQueue.push(msg);
}
void BasebandSampleSource::handleInputMessages()
{
Message* message;

View File

@ -35,11 +35,12 @@ public:
virtual void start() = 0;
virtual void stop() = 0;
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples) = 0;
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
void pushMessage(Message *msg);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
protected:
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
protected slots:

View File

@ -613,7 +613,7 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoInit(int subsystemIndex)
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[isource].begin(); it != m_basebandSampleSinks[isource].end(); ++it)
{
qDebug() << "DSPDeviceMIMOEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(notif);
(*it)->pushMessage(new DSPSignalNotification(notif));
}
}
}
@ -650,7 +650,7 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoInit(int subsystemIndex)
for (BasebandSampleSources::const_iterator it = m_basebandSampleSources[isink].begin(); it != m_basebandSampleSources[isink].end(); ++it)
{
qDebug() << "DSPDeviceMIMOEngine::gotoInit: initializing BasebandSampleSource(" << (*it)->objectName().toStdString().c_str() << ")";
(*it)->handleMessage(notif);
(*it)->pushMessage(new DSPSignalNotification(notif));
}
}
}
@ -956,8 +956,8 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages()
// initialize sample rate and center frequency in the sink:
int sourceStreamSampleRate = m_deviceSampleMIMO->getSourceSampleRate(isource);
quint64 sourceCenterFrequency = m_deviceSampleMIMO->getSourceCenterFrequency(isource);
DSPSignalNotification msg(sourceStreamSampleRate, sourceCenterFrequency);
sink->handleMessage(msg);
DSPSignalNotification *msg = new DSPSignalNotification(sourceStreamSampleRate, sourceCenterFrequency);
sink->pushMessage(msg);
// start the sink:
if (m_stateRx == StRunning) {
sink->start();
@ -991,8 +991,8 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages()
// initialize sample rate and center frequency in the sink:
int sinkStreamSampleRate = m_deviceSampleMIMO->getSinkSampleRate(isink);
quint64 sinkCenterFrequency = m_deviceSampleMIMO->getSinkCenterFrequency(isink);
DSPSignalNotification msg(sinkStreamSampleRate, sinkCenterFrequency);
sampleSource->handleMessage(msg);
DSPSignalNotification *msg = new DSPSignalNotification(sinkStreamSampleRate, sinkCenterFrequency);
sampleSource->pushMessage(msg);
// start the sink:
if (m_stateTx == StRunning) {
sampleSource->start();
@ -1019,24 +1019,24 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages()
for (unsigned int isource = 0; isource < m_deviceSampleMIMO->getNbSourceStreams(); isource++)
{
DSPMIMOSignalNotification notif(
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(
m_deviceSampleMIMO->getSourceSampleRate(isource),
m_deviceSampleMIMO->getSourceCenterFrequency(isource),
true,
isource
);
channel->handleMessage(notif);
channel->pushMessage(notif);
}
for (unsigned int isink = 0; isink < m_deviceSampleMIMO->getNbSinkStreams(); isink++)
{
DSPMIMOSignalNotification notif(
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(
m_deviceSampleMIMO->getSinkSampleRate(isink),
m_deviceSampleMIMO->getSinkCenterFrequency(isink),
false,
isink
);
channel->handleMessage(notif);
channel->pushMessage(notif);
}
if (m_stateRx == StRunning) {
@ -1077,19 +1077,19 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages()
{
if (m_spectrumSink)
{
DSPSignalNotification notif(
DSPSignalNotification *notif = new DSPSignalNotification(
m_deviceSampleMIMO->getSinkSampleRate(spectrumInputIndex),
m_deviceSampleMIMO->getSinkCenterFrequency(spectrumInputIndex));
m_spectrumSink->handleMessage(notif);
m_spectrumSink->pushMessage(notif);
}
}
if (m_spectrumSink && (spectrumInputSourceElseSink) && (spectrumInputIndex < m_deviceSampleMIMO->getNbSinkFifos()))
{
DSPSignalNotification notif(
DSPSignalNotification *notif = new DSPSignalNotification(
m_deviceSampleMIMO->getSourceSampleRate(spectrumInputIndex),
m_deviceSampleMIMO->getSourceCenterFrequency(spectrumInputIndex));
m_spectrumSink->handleMessage(notif);
m_spectrumSink->pushMessage(notif);
}
m_spectrumInputSourceElseSink = spectrumInputSourceElseSink;
@ -1165,22 +1165,22 @@ void DSPDeviceMIMOEngine::handleInputMessages()
for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it)
{
DSPMIMOSignalNotification *message = new DSPMIMOSignalNotification(*notif);
(*it)->handleMessage(*message);
(*it)->pushMessage(message);
}
if (sourceElseSink)
{
if ((istream < m_deviceSampleMIMO->getNbSourceStreams()))
{
DSPSignalNotification *message = new DSPSignalNotification(sampleRate, centerFrequency);
// forward source changes to ancillary sinks with immediate execution (no queuing)
// forward source changes to ancillary sinks
if (istream < m_basebandSampleSinks.size())
{
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks[istream].begin(); it != m_basebandSampleSinks[istream].end(); ++it)
{
DSPSignalNotification *message = new DSPSignalNotification(sampleRate, centerFrequency);
qDebug() << "DSPDeviceMIMOEngine::handleInputMessages: starting " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(*message);
(*it)->pushMessage(message);
}
}
@ -1196,8 +1196,8 @@ void DSPDeviceMIMOEngine::handleInputMessages()
// forward changes to spectrum sink if currently active
if (m_spectrumSink && m_spectrumInputSourceElseSink && (m_spectrumInputIndex == istream))
{
DSPSignalNotification spectrumNotif(sampleRate, centerFrequency);
m_spectrumSink->handleMessage(spectrumNotif);
DSPSignalNotification *spectrumNotif = new DSPSignalNotification(sampleRate, centerFrequency);
m_spectrumSink->pushMessage(spectrumNotif);
}
}
}
@ -1205,15 +1205,15 @@ void DSPDeviceMIMOEngine::handleInputMessages()
{
if ((istream < m_deviceSampleMIMO->getNbSinkStreams()))
{
DSPSignalNotification *message = new DSPSignalNotification(sampleRate, centerFrequency);
// forward source changes to channel sources with immediate execution (no queuing)
if (istream < m_basebandSampleSources.size())
{
for (BasebandSampleSources::const_iterator it = m_basebandSampleSources[istream].begin(); it != m_basebandSampleSources[istream].end(); ++it)
{
DSPSignalNotification *message = new DSPSignalNotification(sampleRate, centerFrequency);
qDebug() << "DSPDeviceMIMOEngine::handleSinkMessages: forward message to BasebandSampleSource(" << (*it)->objectName().toStdString().c_str() << ")";
(*it)->handleMessage(*message);
(*it)->pushMessage(message);
}
}
@ -1229,8 +1229,8 @@ void DSPDeviceMIMOEngine::handleInputMessages()
// forward changes to spectrum sink if currently active
if (m_spectrumSink && !m_spectrumInputSourceElseSink && (m_spectrumInputIndex == istream))
{
DSPSignalNotification spectrumNotif(sampleRate, centerFrequency);
m_spectrumSink->handleMessage(spectrumNotif);
DSPSignalNotification *spectrumNotif = new DSPSignalNotification(sampleRate, centerFrequency);
m_spectrumSink->pushMessage(spectrumNotif);
}
}
}

View File

@ -316,11 +316,11 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoInit()
for (BasebandSampleSources::const_iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it)
{
qDebug() << "DSPDeviceSinkEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(notif);
(*it)->pushMessage(new DSPSignalNotification(notif));
}
if (m_spectrumSink) {
m_spectrumSink->handleMessage(notif);
m_spectrumSink->pushMessage(new DSPSignalNotification(notif));
}
// pass data to listeners
@ -471,8 +471,8 @@ void DSPDeviceSinkEngine::handleSynchronousMessages()
{
BasebandSampleSource* source = ((DSPAddBasebandSampleSource*) message)->getSampleSource();
m_basebandSampleSources.push_back(source);
DSPSignalNotification notif(m_sampleRate, m_centerFrequency);
source->handleMessage(notif);
DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
source->pushMessage(notif);
if (m_state == StRunning)
{
@ -518,8 +518,9 @@ void DSPDeviceSinkEngine::handleInputMessages()
for(BasebandSampleSources::const_iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); it++)
{
DSPSignalNotification* rep = new DSPSignalNotification(*notif); // make a copy
qDebug() << "DSPDeviceSinkEngine::handleInputMessages: forward message to " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(*message);
(*it)->pushMessage(rep);
}
// forward changes to listeners on DSP output queue

View File

@ -440,18 +440,18 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoInit()
<< " sampleRate: " << m_sampleRate
<< " centerFrequency: " << m_centerFrequency;
DSPSignalNotification notif(m_sampleRate, m_centerFrequency);
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it)
{
DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
qDebug() << "DSPDeviceSourceEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(notif);
(*it)->pushMessage(notif);
}
// pass data to listeners
if (m_deviceSampleSource->getMessageQueueToGUI())
{
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy for the output queue
DSPSignalNotification* rep = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
m_deviceSampleSource->getMessageQueueToGUI()->push(rep);
}
@ -581,8 +581,8 @@ void DSPDeviceSourceEngine::handleSynchronousMessages()
BasebandSampleSink* sink = ((DSPAddBasebandSampleSink*) message)->getSampleSink();
m_basebandSampleSinks.push_back(sink);
// initialize sample rate and center frequency in the sink:
DSPSignalNotification msg(m_sampleRate, m_centerFrequency);
sink->handleMessage(msg);
DSPSignalNotification *msg = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
sink->pushMessage(msg);
// start the sink:
if(m_state == StRunning) {
sink->start();
@ -658,8 +658,9 @@ void DSPDeviceSourceEngine::handleInputMessages()
for(BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++)
{
DSPSignalNotification* rep = new DSPSignalNotification(*notif); // make a copy
qDebug() << "DSPDeviceSourceEngine::handleInputMessages: forward message to " << (*it)->objectName().toStdString().c_str();
(*it)->handleMessage(*message);
(*it)->pushMessage(rep);
}
// forward changes to source GUI input queue
@ -667,7 +668,8 @@ void DSPDeviceSourceEngine::handleInputMessages()
MessageQueue *guiMessageQueue = m_deviceSampleSource->getMessageQueueToGUI();
qDebug("DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p", guiMessageQueue);
if (guiMessageQueue) {
if (guiMessageQueue)
{
DSPSignalNotification* rep = new DSPSignalNotification(*notif); // make a copy for the source GUI
guiMessageQueue->push(rep);
}

View File

@ -27,6 +27,11 @@ MIMOChannel::~MIMOChannel()
{
}
void MIMOChannel::pushMessage(Message *msg)
{
m_inputMessageQueue.push(msg);
}
void MIMOChannel::handleInputMessages()
{
Message* message;

View File

@ -39,11 +39,12 @@ public:
virtual void stopSources() = 0;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex) = 0;
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples, unsigned int sourceIndex) = 0;
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
void pushMessage(Message *msg);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
protected:
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
protected slots: