| 
									
										
										
										
											2016-10-17 08:58:49 +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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 <QDebug>
 | 
					
						
							|  |  |  | #include <QThread>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/threadedbasebandsamplesource.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ThreadedBasebandSampleSource::ThreadedBasebandSampleSource(BasebandSampleSource* sampleSource, QObject *parent) : | 
					
						
							|  |  |  |         m_basebandSampleSource(sampleSource) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString name = "ThreadedBasebandSampleSource(" + m_basebandSampleSource->objectName() + ")"; | 
					
						
							|  |  |  |     setObjectName(name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qDebug() << "ThreadedBasebandSampleSource::ThreadedBasebandSampleSource: " << name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_thread = new QThread(parent); | 
					
						
							|  |  |  |     m_basebandSampleSource->moveToThread(m_thread); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     qDebug() << "ThreadedBasebandSampleSource::ThreadedBasebandSampleSource: thread: " << thread() << " m_thread: " << m_thread; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ThreadedBasebandSampleSource::~ThreadedBasebandSampleSource() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-16 10:15:35 +01:00
										 |  |  |     stop(); | 
					
						
							| 
									
										
										
										
											2016-10-17 08:58:49 +02:00
										 |  |  |     delete m_thread; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThreadedBasebandSampleSource::start() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qDebug() << "ThreadedBasebandSampleSource::start"; | 
					
						
							|  |  |  |     m_thread->start(); | 
					
						
							|  |  |  |     m_basebandSampleSource->start(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ThreadedBasebandSampleSource::stop() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qDebug() << "ThreadedBasebandSampleSource::stop"; | 
					
						
							|  |  |  |     m_basebandSampleSource->stop(); | 
					
						
							|  |  |  |     m_thread->exit(); | 
					
						
							|  |  |  |     m_thread->wait(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | void ThreadedBasebandSampleSource::pull(Sample& sample) | 
					
						
							| 
									
										
										
										
											2016-10-17 08:58:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 	m_basebandSampleSource->pull(sample); | 
					
						
							| 
									
										
										
										
											2016-10-17 08:58:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-22 23:39:06 +01:00
										 |  |  | void ThreadedBasebandSampleSource::feed(SampleSourceFifo* sampleFifo, | 
					
						
							|  |  |  | 	int nbSamples) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	m_basebandSampleSource->feed(sampleFifo, nbSamples); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-17 08:58:49 +02:00
										 |  |  | bool ThreadedBasebandSampleSource::handleSourceMessage(const Message& cmd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSampleSource->handleMessage(cmd); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString ThreadedBasebandSampleSource::getSampleSourceObjectName() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_basebandSampleSource->objectName(); | 
					
						
							|  |  |  | } |