2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								///////////////////////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Copyright (C) 2016 F4EXB                                                      //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// written by Edouard Griffiths                                                  //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//                                                                               //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This program is free software; you can redistribute it and/or modify          //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// it under the terms of the GNU General Public License as published by          //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// the Free Software Foundation as version 3 of the License, or                  //
  
						 
					
						
							
								
									
										
										
										
											2019-04-11 14:32:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// (at your option) any later version.                                           //
  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//                                                                               //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// This program is distributed in the hope that it will be useful,               //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// but WITHOUT ANY WARRANTY; without even the implied warranty of                //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// GNU General Public License V3 for more details.                               //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//                                                                               //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// You should have received a copy of the GNU General Public License             //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// along with this program. If not, see <http://www.gnu.org/licenses/>.          //
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								///////////////////////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <stdio.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <QDebug> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <QThread> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "dspdevicesinkengine.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "dsp/basebandsamplesource.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "dsp/basebandsamplesink.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "dsp/devicesamplesink.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "dsp/dspcommands.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "samplesourcefifo.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "threadedbasebandsamplesource.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DSPDeviceSinkEngine : : DSPDeviceSinkEngine ( uint32_t  uid ,  QObject *  parent )  :  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									QThread ( parent ) , 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-25 20:13:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_uid ( uid ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_state ( StNotStarted ) , 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-18 11:59:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_deviceSampleSink ( nullptr ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_sampleSinkSequence ( 0 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_basebandSampleSources ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-18 11:59:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_spectrumSink ( nullptr ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_sampleRate ( 0 ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_centerFrequency ( 0 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_multipleSourcesDivisionFactor ( 1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									connect ( & m_inputMessageQueue ,  SIGNAL ( messageEnqueued ( ) ) ,  this ,  SLOT ( handleInputMessages ( ) ) ,  Qt : : QueuedConnection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									connect ( & m_syncMessenger ,  SIGNAL ( messageSent ( ) ) ,  this ,  SLOT ( handleSynchronousMessages ( ) ) ,  Qt : : QueuedConnection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									moveToThread ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								DSPDeviceSinkEngine : : ~ DSPDeviceSinkEngine ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2018-02-14 11:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    stop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									wait ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : run ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::run " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_state  =  StIdle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									exec ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : start ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::start " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									QThread : : start ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : stop ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::stop " ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-14 11:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    gotoIdle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_state  =  StNotStarted ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    QThread : : exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	DSPExit cmd;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//	m_syncMessenger.sendWait(cmd);
  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  DSPDeviceSinkEngine : : initGeneration ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::initGeneration " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPGenerationInit  cmd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_syncMessenger . sendWait ( cmd )  = =  StReady ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  DSPDeviceSinkEngine : : startGeneration ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::startGeneration " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPGenerationStart  cmd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_syncMessenger . sendWait ( cmd )  = =  StRunning ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : stopGeneration ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::stopGeneration " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPGenerationStop  cmd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_syncMessenger . storeMessage ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									handleSynchronousMessages ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : setSink ( DeviceSampleSink *  sink )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::setSink " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPSetSink  cmd ( sink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : setSinkSequence ( int  sequence )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( " DSPDeviceSinkEngine::setSinkSequence: seq: %d " ,  sequence ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_sampleSinkSequence  =  sequence ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : addThreadedSource ( ThreadedBasebandSampleSource *  source )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::addThreadedSource:  "  < <  source - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DSPAddThreadedBasebandSampleSource  cmd ( source ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : removeThreadedSource ( ThreadedBasebandSampleSource *  source )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::removeThreadedSource:  "  < <  source - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									DSPRemoveThreadedBasebandSampleSource  cmd ( source ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : addSpectrumSink ( BasebandSampleSink *  spectrumSink )  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::addSpectrumSink:  "  < <  spectrumSink - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPAddSpectrumSink  cmd ( spectrumSink ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : removeSpectrumSink ( BasebandSampleSink *  spectrumSink )  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::removeSpectrumSink:  "  < <  spectrumSink - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPRemoveSpectrumSink  cmd ( spectrumSink ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								QString  DSPDeviceSinkEngine : : errorMessage ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::errorMessage " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPGetErrorMessage  cmd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  cmd . getErrorMessage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								QString  DSPDeviceSinkEngine : : sinkDeviceDescription ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::sinkDeviceDescription " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									DSPGetSinkDeviceDescription  cmd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_syncMessenger . sendWait ( cmd ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  cmd . getDeviceDescription ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-21 02:24:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : work ( int  nbWriteSamples )  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2016-12-22 23:39:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// multiple channel sources handling
 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ( m_threadedBasebandSampleSources . size ( )  +  m_basebandSampleSources . size ( ) )  >  1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 23:39:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	    qDebug("DSPDeviceSinkEngine::work: multiple channel sources handling: %u", m_multipleSourcesDivisionFactor);
  
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:11:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    SampleVector : : iterator  writeBegin ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    SampleSourceFifo *  sampleFifo  =  m_deviceSampleSink - > getSampleFifo ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    sampleFifo - > getWriteIterator ( writeBegin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									    SampleVector : : iterator  writeAt  =  writeBegin ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    std : : vector < SampleVector : : iterator >  sampleSourceIterators ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:11:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									    for  ( ThreadedBasebandSampleSources : : iterator  it  =  m_threadedBasebandSampleSources . begin ( ) ;  it  ! =  m_threadedBasebandSampleSources . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 01:39:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									        sampleSourceIterators . push_back ( SampleVector : : iterator ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        ( * it ) - > getSampleSourceFifo ( ) . readAdvance ( sampleSourceIterators . back ( ) ,  nbWriteSamples ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        sampleSourceIterators . back ( )  - =  nbWriteSamples ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 01:39:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    } 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:11:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    for  ( BasebandSampleSources : : iterator  it  =  m_basebandSampleSources . begin ( ) ;  it  ! =  m_basebandSampleSources . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									    { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            sampleSourceIterators . push_back ( SampleVector : : iterator ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ( * it ) - > getSampleSourceFifo ( ) . readAdvance ( sampleSourceIterators . back ( ) ,  nbWriteSamples ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            sampleSourceIterators . back ( )  - =  nbWriteSamples ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    } 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:11:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    for  ( int  is  =  0 ;  is  <  nbWriteSamples ;  is + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// pull data from sources FIFOs and merge them in the device sample FIFO
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        for  ( std : : vector < SampleVector : : iterator > : : iterator  it  =  sampleSourceIterators . begin ( ) ;  it  ! =  sampleSourceIterators . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            Sample  s  =  ( * * it ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            s  / =  m_multipleSourcesDivisionFactor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            + + ( * it ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            if  ( it  = =  sampleSourceIterators . begin ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									                ( * writeAt )  =  s ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									                ( * writeAt )  + =  s ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        } 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:11:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-26 12:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											sampleFifo - > bumpIndex ( writeAt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// notStarted -> idle -> init -> running -+
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//                ^                       |
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//                +-----------------------+
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								DSPDeviceSinkEngine : : State  DSPDeviceSinkEngine : : gotoIdle ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::gotoIdle " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									switch ( m_state )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  StNotStarted : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  StNotStarted ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  StIdle : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  StError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  StIdle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  StReady : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  StRunning : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( m_deviceSampleSink  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  StIdle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// stop everything
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for ( BasebandSampleSources : : const_iterator  it  =  m_basebandSampleSources . begin ( ) ;  it  ! =  m_basebandSampleSources . end ( ) ;  it + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-25 21:26:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        qDebug ( )  < <  " DSPDeviceSinkEngine::gotoIdle: stopping  "  < <  ( * it ) - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										( * it ) - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for ( ThreadedBasebandSampleSources : : const_iterator  it  =  m_threadedBasebandSampleSources . begin ( ) ;  it  ! =  m_threadedBasebandSampleSources . end ( ) ;  it + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-25 21:26:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									    qDebug ( )  < <  " DSPDeviceSinkEngine::gotoIdle: stopping ThreadedSampleSource( "  < <  ( * it ) - > getSampleSourceObjectName ( ) . toStdString ( ) . c_str ( )  < <  " ) " ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										( * it ) - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-27 11:10:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_spectrumSink ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        disconnect ( m_deviceSampleSink - > getSampleFifo ( ) ,  SIGNAL ( dataRead ( int ) ) ,  this ,  SLOT ( handleForwardToSpectrumSink ( int ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_spectrumSink - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:31:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_deviceSampleSink - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_deviceDescription . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_sampleRate  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  StIdle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								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 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-25 09:10:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::gotoInit:  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									        < <  "  m_deviceDescription:  "  < <  m_deviceDescription . toStdString ( ) . c_str ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											< <  "  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 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-27 11:10:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_spectrumSink )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_spectrumSink - > handleMessage ( notif ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// pass data to listeners
 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 17:35:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_deviceSampleSink - > getMessageQueueToGUI ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        DSPSignalNotification *  rep  =  new  DSPSignalNotification ( notif ) ;  // make a copy for the output queue
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_deviceSampleSink - > getMessageQueueToGUI ( ) - > push ( rep ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  StReady ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								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
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-14 03:44:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( ! m_deviceSampleSink - > start ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-09-18 23:12:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  gotoError ( " DSPDeviceSinkEngine::gotoRunning: Could not start sample sink " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									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 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-27 11:10:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_spectrumSink ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        connect ( m_deviceSampleSink - > getSampleFifo ( ) ,  SIGNAL ( dataRead ( int ) ) ,  this ,  SLOT ( handleForwardToSpectrumSink ( int ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_spectrumSink - > start ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::gotoRunning: input message queue pending:  "  < <  m_inputMessageQueue . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  StRunning ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								DSPDeviceSinkEngine : : State  DSPDeviceSinkEngine : : gotoError ( const  QString &  errorMessage )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::gotoError " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_errorMessage  =  errorMessage ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_deviceDescription . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_state  =  StError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  StError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : handleSetSink ( DeviceSampleSink *  sink )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									gotoIdle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_deviceSampleSink  =  sink ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-18 11:59:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( m_deviceSampleSink  ! =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										qDebug ( " DSPDeviceSinkEngine::handleSetSink: set %s " ,  qPrintable ( sink - > getDeviceDescription ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-18 11:59:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										qDebug ( " DSPDeviceSinkEngine::handleSetSource: set none " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-21 02:24:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : handleData ( int  nbSamples )  
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( m_state  = =  StRunning ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-21 02:24:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										work ( nbSamples ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : handleSynchronousMessages ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Message  * message  =  m_syncMessenger . getMessage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									qDebug ( )  < <  " DSPDeviceSinkEngine::handleSynchronousMessages:  "  < <  message - > getIdentifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-14 17:33:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( DSPGenerationInit : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_state  =  gotoIdle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( m_state  = =  StIdle )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_state  =  gotoInit ( ) ;  // State goes ready if init is performed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( DSPGenerationStart : : match ( * message ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( m_state  = =  StReady )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_state  =  gotoRunning ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( DSPGenerationStop : : match ( * message ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_state  =  gotoIdle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( DSPGetSinkDeviceDescription : : match ( * message ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( ( DSPGetSinkDeviceDescription * )  message ) - > setDeviceDescription ( m_deviceDescription ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( DSPGetErrorMessage : : match ( * message ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( ( DSPGetErrorMessage * )  message ) - > setErrorMessage ( m_errorMessage ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( DSPSetSink : : match ( * message ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										handleSetSink ( ( ( DSPSetSink * )  message ) - > getSampleSink ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPAddSpectrumSink : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_spectrumSink  =  ( ( DSPAddSpectrumSink * )  message ) - > getSampleSink ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPRemoveSpectrumSink : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										BasebandSampleSink *  spectrumSink  =  ( ( DSPRemoveSpectrumSink * )  message ) - > getSampleSink ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( m_state  = =  StRunning )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											spectrumSink - > stop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:06:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_spectrumSink  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPAddBasebandSampleSource : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										BasebandSampleSource *  source  =  ( ( DSPAddBasebandSampleSource * )  message ) - > getSampleSource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_basebandSampleSources . push_back ( source ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 16:25:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        DSPSignalNotification  notif ( m_sampleRate ,  m_centerFrequency ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        source - > handleMessage ( notif ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										checkNumberOfBasebandSources ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 11:00:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_state  = =  StRunning ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            source - > start ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPRemoveBasebandSampleSource : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										BasebandSampleSource *  source  =  ( ( DSPRemoveBasebandSampleSource * )  message ) - > getSampleSource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( m_state  = =  StRunning )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											source - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_basebandSampleSources . remove ( source ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										checkNumberOfBasebandSources ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPAddThreadedBasebandSampleSource : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ThreadedBasebandSampleSource  * threadedSource  =  ( ( DSPAddThreadedBasebandSampleSource * )  message ) - > getThreadedSampleSource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_threadedBasebandSampleSources . push_back ( threadedSource ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 16:25:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        DSPSignalNotification  notif ( m_sampleRate ,  m_centerFrequency ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        threadedSource - > handleSourceMessage ( notif ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										checkNumberOfBasebandSources ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 11:00:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_state  = =  StRunning ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            threadedSource - > start ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else  if  ( DSPRemoveThreadedBasebandSampleSource : : match ( * message ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ThreadedBasebandSampleSource *  threadedSource  =  ( ( DSPRemoveThreadedBasebandSampleSource * )  message ) - > getThreadedSampleSource ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-17 23:41:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_state  = =  StRunning )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										    threadedSource - > stop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_threadedBasebandSampleSources . remove ( threadedSource ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										checkNumberOfBasebandSources ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_syncMessenger . done ( m_state ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : handleInputMessages ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Message *  message ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( ( message  =  m_inputMessageQueue . pop ( ) )  ! =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										qDebug ( " DSPDeviceSinkEngine::handleInputMessages: message: %s " ,  message - > getIdentifier ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( DSPSignalNotification : : match ( * message ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											DSPSignalNotification  * notif  =  ( DSPSignalNotification  * )  message ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// update DSP values
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_sampleRate  =  notif - > getSampleRate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_centerFrequency  =  notif - > getCenterFrequency ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-04 10:49:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											qDebug ( )  < <  " DSPDeviceSinkEngine::handleInputMessages: DSPSignalNotification: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												< <  "  m_sampleRate:  "  < <  m_sampleRate 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												< <  "  m_centerFrequency:  "  < <  m_centerFrequency ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // forward source changes to sources with immediate execution
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for ( BasebandSampleSources : : const_iterator  it  =  m_basebandSampleSources . begin ( ) ;  it  ! =  m_basebandSampleSources . end ( ) ;  it + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												qDebug ( )  < <  " DSPDeviceSinkEngine::handleInputMessages: forward message to  "  < <  ( * it ) - > objectName ( ) . toStdString ( ) . c_str ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												( * it ) - > handleMessage ( * message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( ThreadedBasebandSampleSources : : const_iterator  it  =  m_threadedBasebandSampleSources . begin ( ) ;  it  ! =  m_threadedBasebandSampleSources . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												qDebug ( )  < <  " DSPDeviceSinkEngine::handleSourceMessages: forward message to ThreadedSampleSource( "  < <  ( * it ) - > getSampleSourceObjectName ( ) . toStdString ( ) . c_str ( )  < <  " ) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												( * it ) - > handleSourceMessage ( * message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// forward changes to listeners on DSP output queue
 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-04 10:49:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											MessageQueue  * guiMessageQueue  =  m_deviceSampleSink - > getMessageQueueToGUI ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											qDebug ( " DSPDeviceSinkEngine::handleInputMessages: DSPSignalNotification: guiMessageQueue: %p " ,  guiMessageQueue ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( guiMessageQueue ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 17:35:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                DSPSignalNotification *  rep  =  new  DSPSignalNotification ( * notif ) ;  // make a copy for the output queue
 
							 
						 
					
						
							
								
									
										
										
										
											2019-01-04 10:49:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                guiMessageQueue - > push ( rep ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 17:35:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-23 23:27:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											delete  message ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-24 18:31:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : handleForwardToSpectrumSink ( int  nbSamples )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_spectrumSink ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SampleSourceFifo *  sampleFifo  =  m_deviceSampleSink - > getSampleFifo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SampleVector : : iterator  readUntil ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										sampleFifo - > getReadIterator ( readUntil ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_spectrumSink - > feed ( readUntil  -  nbSamples ,  readUntil ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  DSPDeviceSinkEngine : : checkNumberOfBasebandSources ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    SampleSourceFifo *  sampleFifo  =  m_deviceSampleSink - > getSampleFifo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // single channel source handling
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ( m_threadedBasebandSampleSources . size ( )  +  m_basebandSampleSources . size ( ) )  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        qDebug ( " DSPDeviceSinkEngine::checkNumberOfBasebandSources: single channel mode " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        disconnect ( sampleFifo ,  SIGNAL ( dataWrite ( int ) ) ,  this ,  SLOT ( handleData ( int ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_threadedBasebandSampleSources . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_threadedBasebandSampleSources . back ( ) - > setDeviceSampleSourceFifo ( sampleFifo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( m_basebandSampleSources . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-27 17:45:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_basebandSampleSources . back ( ) - > setDeviceSampleSourceFifo ( sampleFifo ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_multipleSourcesDivisionFactor  =  1 ;  // for consistency but it is not used in this case
 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // null or multiple channel sources handling
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        int  nbSources  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( ThreadedBasebandSampleSources : : iterator  it  =  m_threadedBasebandSampleSources . begin ( ) ;  it  ! =  m_threadedBasebandSampleSources . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ( * it ) - > setDeviceSampleSourceFifo ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            nbSources + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( BasebandSampleSources : : iterator  it  =  m_basebandSampleSources . begin ( ) ;  it  ! =  m_basebandSampleSources . end ( ) ;  + + it ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ( * it ) - > setDeviceSampleSourceFifo ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            nbSources + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( nbSources  = =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_multipleSourcesDivisionFactor  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( nbSources  <  3 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_multipleSourcesDivisionFactor  =  nbSources ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_multipleSourcesDivisionFactor  =  1 < < nbSources ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 04:01:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( nbSources  >  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 03:40:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            connect ( sampleFifo ,  SIGNAL ( dataWrite ( int ) ) ,  this ,  SLOT ( handleData ( int ) ) ,  Qt : : QueuedConnection ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        qDebug ( " DSPDeviceSinkEngine::checkNumberOfBasebandSources: handle %d channel(s) " ,  nbSources ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-02 02:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}