mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-17 23:28:50 -05:00
Deep redesign: phase #3
This commit is contained in:
parent
f5c5e19571
commit
b5f2475fbf
@ -118,6 +118,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
|
||||
void handleSourceMessages(); //!< Handle source message output
|
||||
void handleInputMessages(); //!< Handle input message queue
|
||||
void handleSynchronousMessages(Message *message); //!< Handle synchronous messages with the thread
|
||||
};
|
||||
|
@ -34,8 +34,8 @@ public:
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual const QString& getDeviceDescription() const = 0;
|
||||
virtual int getSampleRate() const = 0;
|
||||
virtual quint64 getCenterFrequency() const = 0;
|
||||
virtual int getSampleRate() const { return m_sampleRate; };
|
||||
virtual quint64 getCenterFrequency() const { return m_centerFrequency; };
|
||||
|
||||
virtual bool handleMessage(const Message& message) = 0;
|
||||
|
||||
@ -44,9 +44,15 @@ public:
|
||||
SampleFifo* getSampleFifo() { return &m_sampleFifo; }
|
||||
|
||||
protected:
|
||||
void setSampleRate(int sampleRate);
|
||||
void setCenterFrequency(quint64 centerFrequency);
|
||||
void sendNewData();
|
||||
|
||||
SampleFifo m_sampleFifo;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
MessageQueue m_outputMessageQueue;
|
||||
int m_sampleRate;
|
||||
quint64 m_centerFrequency;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SAMPLESOURCE_H
|
||||
|
@ -438,6 +438,7 @@ void DSPEngine::handleSetSource(SampleSource* source)
|
||||
if(m_sampleSource != 0)
|
||||
{
|
||||
disconnect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()));
|
||||
disconnect(m_sampleSource->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
||||
}
|
||||
|
||||
m_sampleSource = source;
|
||||
@ -446,6 +447,7 @@ void DSPEngine::handleSetSource(SampleSource* source)
|
||||
{
|
||||
qDebug() << " - connect";
|
||||
connect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection);
|
||||
connect(m_sampleSource->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,3 +568,38 @@ void DSPEngine::handleInputMessages()
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEngine::handleSourceMessages()
|
||||
{
|
||||
Message *message;
|
||||
|
||||
qDebug() << "DSPEngine::handleSourceMessages";
|
||||
|
||||
while ((message = m_sampleSource->getOutputMessageQueue()->pop()) != 0)
|
||||
{
|
||||
if (DSPSignalNotification::match(message))
|
||||
{
|
||||
DSPSignalNotification *notif = (DSPSignalNotification *) &message;
|
||||
|
||||
// update DSP values
|
||||
|
||||
m_sampleRate = notif->getSampleRate();
|
||||
m_centerFrequency = notif->getFrequencyOffset();
|
||||
|
||||
// forward source changes to sinks
|
||||
|
||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||
{
|
||||
qDebug() << " - initializing " << (*it)->objectName().toStdString().c_str();
|
||||
(*it)->init(*message);
|
||||
}
|
||||
|
||||
// forward changes to listeners
|
||||
|
||||
DSPEngineReport* rep = new DSPEngineReport(m_sampleRate, m_centerFrequency);
|
||||
m_outputMessageQueue.push(rep);
|
||||
}
|
||||
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
|
@ -16,54 +16,41 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dsp/samplesource/samplesource.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SampleSource::GeneralSettings::GeneralSettings() :
|
||||
m_centerFrequency(100000000)
|
||||
{
|
||||
}
|
||||
|
||||
void SampleSource::GeneralSettings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 100000000;
|
||||
}
|
||||
|
||||
QByteArray SampleSource::GeneralSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeU64(1, m_centerFrequency);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool SampleSource::GeneralSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if(!d.isValid()) {
|
||||
qDebug() << "SampleSource::GeneralSettings::deserialize: invalid deserializer";
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(d.getVersion() == 1) {
|
||||
d.readU64(1, &m_centerFrequency, 100000000);
|
||||
qDebug() << "SampleSource::GeneralSettings::deserialize: center frequency = "
|
||||
<< m_centerFrequency;
|
||||
return true;
|
||||
} else {
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SampleSource::SampleSource(MessageQueue* guiMessageQueue) :
|
||||
m_sampleFifo(),
|
||||
m_guiMessageQueue(guiMessageQueue)
|
||||
SampleSource::SampleSource() :
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0)
|
||||
{
|
||||
}
|
||||
|
||||
SampleSource::~SampleSource()
|
||||
{
|
||||
}
|
||||
|
||||
void SampleSource::setSampleRate(int sampleRate)
|
||||
{
|
||||
if (sampleRate != m_sampleRate)
|
||||
{
|
||||
// TODO: adjust FIFO size
|
||||
m_sampleRate = sampleRate;
|
||||
sendNewData();
|
||||
}
|
||||
}
|
||||
|
||||
void SampleSource::setCenterFrequency(quint64 centerFrequency)
|
||||
{
|
||||
if (centerFrequency != m_centerFrequency)
|
||||
{
|
||||
m_centerFrequency = centerFrequency;
|
||||
sendNewData();
|
||||
}
|
||||
}
|
||||
|
||||
void SampleSource::sendNewData()
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_sampleRate, m_centerFrequency);
|
||||
m_outputMessageQueue.push(notif);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user