1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-09 17:22:27 -04:00

Fixed startup initialization sequence: interim state #2

This commit is contained in:
f4exb 2015-08-13 01:14:21 +02:00
parent a7da0b76e2
commit 7433cdd91e
3 changed files with 53 additions and 77 deletions

View File

@ -141,5 +141,4 @@ To Do
- Tx channels for Rx/Tx boards like BladeRF - Tx channels for Rx/Tx boards like BladeRF
- Enhance WFM (stereo, RDS?) - Enhance WFM (stereo, RDS?)
- Even more demods ... - Even more demods ...
- ASRP4 support

View File

@ -52,7 +52,10 @@ void Channelizer::feed(SampleVector::const_iterator begin, SampleVector::const_i
void Channelizer::start() void Channelizer::start()
{ {
if(m_sampleSink != NULL) if(m_sampleSink != NULL)
{
qDebug() << "Channelizer::start";
m_sampleSink->start(); m_sampleSink->start();
}
} }
void Channelizer::stop() void Channelizer::stop()

View File

@ -328,7 +328,7 @@ DSPEngine::State DSPEngine::gotoInit()
case StNotStarted: case StNotStarted:
return StNotStarted; return StNotStarted;
case StRunning: case StRunning: // FIXME: assumes it goes first through idle state. Could we get back to init from running directly?
return StRunning; return StRunning;
case StReady: case StReady:
@ -344,22 +344,26 @@ DSPEngine::State DSPEngine::gotoInit()
return gotoError("No sample source configured"); return gotoError("No sample source configured");
} }
// init: pass sample rate to all sample rate dependent sinks waiting for completion // init: pass sample rate and center frequency to all sample rate and/or center frequency dependent sinks and wait for completion
m_iOffset = 0;
m_qOffset = 0;
m_iRange = 1 << 16;
m_qRange = 1 << 16;
m_deviceDescription = m_sampleSource->getDeviceDescription(); m_deviceDescription = m_sampleSource->getDeviceDescription();
m_centerFrequency = m_sampleSource->getCenterFrequency(); m_centerFrequency = m_sampleSource->getCenterFrequency();
m_sampleRate = m_sampleSource->getSampleRate(); m_sampleRate = m_sampleSource->getSampleRate();
qDebug() << "DSPEngine::gotoInit: " << m_deviceDescription.toStdString().c_str()
<< ": sampleRate: " << m_sampleRate qDebug() << "DSPEngine::gotoInit: " << m_deviceDescription.toStdString().c_str() << ": "
<< " sampleRate: " << m_sampleRate
<< " centerFrequency: " << m_centerFrequency; << " centerFrequency: " << m_centerFrequency;
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
{ {
qDebug() << " - " << (*it)->objectName().toStdString().c_str(); qDebug() << " - initializing " << (*it)->objectName().toStdString().c_str();
DSPSignalNotification* notif = DSPSignalNotification::create(m_sampleRate, 0); DSPSignalNotification* notif = DSPSignalNotification::create(m_sampleRate, m_centerFrequency);
//notif->execute(&m_outputMessageQueue, *it); // wait for completion (*it)->executeMessage(notif); // this one does not use queuing and thus waits for completion
(*it)->executeMessage(notif);
(*it)->start();
} }
// pass sample rate to main window // pass sample rate to main window
@ -372,7 +376,10 @@ DSPEngine::State DSPEngine::gotoInit()
DSPEngine::State DSPEngine::gotoRunning() DSPEngine::State DSPEngine::gotoRunning()
{ {
switch(m_state) { qDebug() << "DSPEngine::gotoRunning";
switch(m_state)
{
case StNotStarted: case StNotStarted:
return StNotStarted; return StNotStarted;
@ -391,12 +398,7 @@ DSPEngine::State DSPEngine::gotoRunning()
return gotoError("No sample source configured"); return gotoError("No sample source configured");
} }
qDebug() << "DSPEngine::gotoRunning: " << m_deviceDescription.toStdString().c_str() << " started"; qDebug() << " - " << m_deviceDescription.toStdString().c_str() << " started";
m_iOffset = 0;
m_qOffset = 0;
m_iRange = 1 << 16;
m_qRange = 1 << 16;
// Start everything // Start everything
@ -409,11 +411,11 @@ DSPEngine::State DSPEngine::gotoRunning()
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
{ {
qDebug() << " - starting " << (*it)->objectName().toStdString().c_str();
(*it)->start(); (*it)->start();
} }
m_sampleRate = 0; // make sure, report is sent qDebug() << " - input message queue pending: " << m_inputMessageQueue.countPending();
//generateReport();
return StRunning; return StRunning;
} }
@ -428,85 +430,57 @@ DSPEngine::State DSPEngine::gotoError(const QString& errorMessage)
void DSPEngine::handleSetSource(SampleSource* source) void DSPEngine::handleSetSource(SampleSource* source)
{ {
qDebug() << "DSPEngine::handleSetSource: " << source->getDeviceDescription().toStdString().c_str();
gotoIdle(); gotoIdle();
if(m_sampleSource != NULL)
if(m_sampleSource != 0)
{
disconnect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData())); disconnect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()));
}
m_sampleSource = source; m_sampleSource = source;
if(m_sampleSource != NULL)
if(m_sampleSource != 0)
{
qDebug() << " - connect";
connect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection); connect(m_sampleSource->getSampleFifo(), SIGNAL(dataReady()), this, SLOT(handleData()), Qt::QueuedConnection);
//generateReport(); }
} }
/*
void DSPEngine::generateReport()
{
bool needReport = false;
unsigned int sampleRate;
quint64 centerFrequency;
if (m_sampleSource != NULL)
{
sampleRate = m_sampleSource->getSampleRate();
centerFrequency = m_sampleSource->getCenterFrequency();
}
else
{
sampleRate = 0;
centerFrequency = 0;
}
qDebug() << "DSPEngine::generateReport:"
<< " sampleRate: " << sampleRate
<< " centerFrequency: " << centerFrequency;
if (sampleRate != m_sampleRate)
{
m_sampleRate = sampleRate;
needReport = true;
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
{
DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0);
signal->submit(&m_reportQueue, *it);
}
}
if (centerFrequency != m_centerFrequency)
{
m_centerFrequency = centerFrequency;
needReport = true;
}
if (needReport)
{
Message* rep = DSPEngineReport::create(m_sampleRate, m_centerFrequency);
rep->submit(&m_reportQueue);
}
}*/
bool DSPEngine::distributeMessage(Message* message) bool DSPEngine::distributeMessage(Message* message)
{ {
if(m_sampleSource != NULL) { if (m_sampleSource != 0)
if((message->getDestination() == NULL) || (message->getDestination() == m_sampleSource)) { {
if(m_sampleSource->handleMessage(message)) { if ((message->getDestination() == 0) || (message->getDestination() == m_sampleSource))
//generateReport(); {
if (m_sampleSource->handleMessage(message))
{
return true; return true;
} }
} }
} }
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) {
if((message->getDestination() == NULL) || (message->getDestination() == *it)) { for (SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
if((*it)->handleMessage(message)) {
if ((message->getDestination() == NULL) || (message->getDestination() == *it))
{
if ((*it)->handleMessage(message))
{
return true; return true;
}
} }
} }
return false; return false;
} }
void DSPEngine::handleData() void DSPEngine::handleData()
{ {
if(m_state == StRunning) if(m_state == StRunning)
{
work(); work();
}
} }
void DSPEngine::handleInputMessages() void DSPEngine::handleInputMessages()
@ -533,7 +507,7 @@ void DSPEngine::handleInputMessages()
m_state = gotoIdle(); m_state = gotoIdle();
if(m_state == StIdle) { if(m_state == StIdle) {
m_state = gotoInit(); // State goes ready if OK or stays idle m_state = gotoInit(); // State goes ready if init is performed
} }
message->completed(m_state); message->completed(m_state);