void DSPEngine::generateReport() { unsigned int sampleRate; quint64 tunerFrequency; if(m_sampleSource != NULL) { sampleRate = m_sampleSource->getSampleRate(); tunerFrequency = m_sampleSource->getCenterFrequency(); } else { sampleRate = 100000; tunerFrequency = 100000000; } if((sampleRate != m_sampleRate) || (tunerFrequency != m_tunerFrequency)) { m_sampleRate = sampleRate; m_tunerFrequency = tunerFrequency; for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) { DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0, tunerFrequency); signal->submit(&m_messageQueue, *it); } Message* rep = DSPEngineReport::create(m_sampleRate, m_tunerFrequency); rep->submit(m_reportQueue); } }
void DSPEngine::handleMessages() { Message* message; while((message = m_messageQueue.accept()) != NULL) { qDebug("Message: %s", message->getIdentifier()); if(DSPPing::match(message)) { message->completed(m_state); } else if(DSPExit::match(message)) { gotoIdle(); m_state = StNotStarted; exit(); message->completed(m_state); } else if(DSPAcquisitionStart::match(message)) { m_state = gotoIdle(); if(m_state == StIdle) m_state = gotoRunning(); message->completed(m_state); } else if(DSPAcquisitionStop::match(message)) { m_state = gotoIdle(); message->completed(m_state); } else if(DSPGetDeviceDescription::match(message)) { ((DSPGetDeviceDescription*)message)->setDeviceDescription(m_deviceDescription); message->completed(); } else if(DSPGetErrorMessage::match(message)) { ((DSPGetErrorMessage*)message)->setErrorMessage(m_errorMessage); message->completed(); } else if(DSPSetSource::match(message)) { handleSetSource(((DSPSetSource*)message)->getSampleSource()); message->completed(); } else if(DSPAddSink::match(message)) { SampleSink* sink = ((DSPAddSink*)message)->getSampleSink(); if(m_state == StRunning) { DSPSignalNotification* signal = DSPSignalNotification::create(m_sampleRate, 0, m_tunerFrequency); signal->submit(&m_messageQueue, sink); sink->start(); } m_sampleSinks.push_back(sink); message->completed(); } else if(DSPRemoveSink::match(message)) { SampleSink* sink = ((DSPAddSink*)message)->getSampleSink(); if(m_state == StRunning) sink->stop(); m_sampleSinks.remove(sink); message->completed(); } else if(DSPAddAudioSource::match(message)) { m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo()); message->completed(); } else if(DSPRemoveAudioSource::match(message)) { m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo()); message->completed(); } else if(DSPConfigureCorrection::match(message)) { DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message; m_iqImbalanceCorrection = conf->getIQImbalanceCorrection(); if(m_dcOffsetCorrection != conf->getDCOffsetCorrection()) { m_dcOffsetCorrection = conf->getDCOffsetCorrection(); m_iOffset = 0; m_qOffset = 0; } if(m_iqImbalanceCorrection != conf->getIQImbalanceCorrection()) { m_iqImbalanceCorrection = conf->getIQImbalanceCorrection(); m_iRange = 1 << 16; m_qRange = 1 << 16; m_imbalance = 65536; } message->completed(); } else { if(!distributeMessage(message)) message->completed(); } } }