diff --git a/sdrbase/dsp/basebandsamplesink.cpp b/sdrbase/dsp/basebandsamplesink.cpp index 8d572436e..d5b8ec56f 100644 --- a/sdrbase/dsp/basebandsamplesink.cpp +++ b/sdrbase/dsp/basebandsamplesink.cpp @@ -28,6 +28,11 @@ BasebandSampleSink::~BasebandSampleSink() { } +void BasebandSampleSink::pushMessage(Message *msg) +{ + m_inputMessageQueue.push(msg); +} + void BasebandSampleSink::handleInputMessages() { Message* message; diff --git a/sdrbase/dsp/basebandsamplesink.h b/sdrbase/dsp/basebandsamplesink.h index 48cc4a0cd..506b92656 100644 --- a/sdrbase/dsp/basebandsamplesink.h +++ b/sdrbase/dsp/basebandsamplesink.h @@ -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: diff --git a/sdrbase/dsp/basebandsamplesource.cpp b/sdrbase/dsp/basebandsamplesource.cpp index 7fc02f241..674d76f49 100644 --- a/sdrbase/dsp/basebandsamplesource.cpp +++ b/sdrbase/dsp/basebandsamplesource.cpp @@ -28,6 +28,11 @@ BasebandSampleSource::~BasebandSampleSource() { } +void BasebandSampleSource::pushMessage(Message *msg) +{ + m_inputMessageQueue.push(msg); +} + void BasebandSampleSource::handleInputMessages() { Message* message; diff --git a/sdrbase/dsp/basebandsamplesource.h b/sdrbase/dsp/basebandsamplesource.h index 28ea5f7bb..57df4eaed 100644 --- a/sdrbase/dsp/basebandsamplesource.h +++ b/sdrbase/dsp/basebandsamplesource.h @@ -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: diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index 6f25f2ec9..9c9de5807 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -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); } } } diff --git a/sdrbase/dsp/dspdevicesinkengine.cpp b/sdrbase/dsp/dspdevicesinkengine.cpp index dce53868f..ec6e1a077 100644 --- a/sdrbase/dsp/dspdevicesinkengine.cpp +++ b/sdrbase/dsp/dspdevicesinkengine.cpp @@ -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 diff --git a/sdrbase/dsp/dspdevicesourceengine.cpp b/sdrbase/dsp/dspdevicesourceengine.cpp index 2808790cb..2120269c8 100644 --- a/sdrbase/dsp/dspdevicesourceengine.cpp +++ b/sdrbase/dsp/dspdevicesourceengine.cpp @@ -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); } diff --git a/sdrbase/dsp/mimochannel.cpp b/sdrbase/dsp/mimochannel.cpp index c12a2fc79..f62efbe9b 100644 --- a/sdrbase/dsp/mimochannel.cpp +++ b/sdrbase/dsp/mimochannel.cpp @@ -27,6 +27,11 @@ MIMOChannel::~MIMOChannel() { } +void MIMOChannel::pushMessage(Message *msg) +{ + m_inputMessageQueue.push(msg); +} + void MIMOChannel::handleInputMessages() { Message* message; diff --git a/sdrbase/dsp/mimochannel.h b/sdrbase/dsp/mimochannel.h index 48b8d062d..53681ef84 100644 --- a/sdrbase/dsp/mimochannel.h +++ b/sdrbase/dsp/mimochannel.h @@ -39,15 +39,16 @@ 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: void handleInputMessages(); }; -#endif // SDRBASE_MIMOCHANNEL_H \ No newline at end of file +#endif // SDRBASE_MIMOCHANNEL_H