DSPEngine::State DSPEngine::gotoRunning() { switch(m_state) { case StNotStarted: return StNotStarted; case StRunning: return StRunning; case StIdle: case StError: break; } if(m_sampleSource == NULL) return gotoError("No sample source configured"); m_iOffset = 0; m_qOffset = 0; m_iRange = 1 << 16; m_qRange = 1 << 16; if(!m_sampleSource->startInput(0)) return gotoError("Could not start sample source"); m_deviceDescription = m_sampleSource->getDeviceDescription(); m_audioOutput.start(0, 48000); for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) (*it)->start(); m_sampleRate = 0; // make sure, report is sent generateReport(); return StRunning; }
DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoRunning() { qDebug() << "DSPDeviceSinkEngine::gotoRunning"; switch(m_state) { case StNotStarted: return StNotStarted; case StIdle: return StIdle; case StRunning: return StRunning; case StReady: case StError: break; } if(m_deviceSampleSink == 0) { return gotoError("DSPDeviceSinkEngine::gotoRunning: No sample source configured"); } qDebug() << "DSPDeviceSinkEngine::gotoRunning: " << m_deviceDescription.toStdString().c_str() << " started"; // Start everything if(!m_deviceSampleSink->start()) { return gotoError("DSPDeviceSinkEngine::gotoRunning: Could not start sample sink"); } for(BasebandSampleSources::const_iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); it++) { qDebug() << "DSPDeviceSinkEngine::gotoRunning: starting " << (*it)->objectName().toStdString().c_str(); (*it)->start(); } for (ThreadedBasebandSampleSources::const_iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it) { qDebug() << "DSPDeviceSinkEngine::gotoRunning: starting ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() << ")"; (*it)->start(); } if (m_spectrumSink) { connect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataRead(int)), this, SLOT(handleForwardToSpectrumSink(int))); m_spectrumSink->start(); } qDebug() << "DSPDeviceSinkEngine::gotoRunning: input message queue pending: " << m_inputMessageQueue.size(); return StRunning; }
DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoInit() { switch(m_state) { case StNotStarted: return StNotStarted; case StRunning: // FIXME: assumes it goes first through idle state. Could we get back to init from running directly? return StRunning; case StReady: return StReady; case StIdle: case StError: break; } if (m_deviceSampleSink == 0) { return gotoError("DSPDeviceSinkEngine::gotoInit: No sample source configured"); } // init: pass sample rate and center frequency to all sample rate and/or center frequency dependent sinks and wait for completion m_deviceDescription = m_deviceSampleSink->getDeviceDescription(); m_centerFrequency = m_deviceSampleSink->getCenterFrequency(); m_sampleRate = m_deviceSampleSink->getSampleRate(); qDebug() << "DSPDeviceSinkEngine::gotoInit: " << " m_deviceDescription: " << m_deviceDescription.toStdString().c_str() << " sampleRate: " << m_sampleRate << " centerFrequency: " << m_centerFrequency; DSPSignalNotification notif(m_sampleRate, m_centerFrequency); 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); } for (ThreadedBasebandSampleSources::const_iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it) { qDebug() << "DSPDeviceSinkEngine::gotoInit: initializing ThreadedSampleSource(" << (*it)->getSampleSourceObjectName().toStdString().c_str() << ")"; (*it)->handleSourceMessage(notif); } if (m_spectrumSink) { m_spectrumSink->handleMessage(notif); } // pass data to listeners if (m_deviceSampleSink->getMessageQueueToGUI()) { DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy for the output queue m_deviceSampleSink->getMessageQueueToGUI()->push(rep); } return StReady; }