| 
									
										
										
										
											2016-10-17 18:15:08 +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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_
 | 
					
						
							|  |  |  | #define SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QMutex>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-22 23:39:06 +01:00
										 |  |  | #include "dsp/basebandsamplesource.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | #include "util/messagequeue.h"
 | 
					
						
							|  |  |  | #include "util/export.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class BasebandSampleSource; | 
					
						
							|  |  |  | class QThread; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * This class is a wrapper for BasebandSampleSource that runs the BasebandSampleSource object in its own thread | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class SDRANGEL_API ThreadedBasebandSampleSource : public QObject { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	ThreadedBasebandSampleSource(BasebandSampleSource* sampleSource, QObject *parent = 0); | 
					
						
							|  |  |  | 	~ThreadedBasebandSampleSource(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const BasebandSampleSource *getSource() const { return m_basebandSampleSource; } | 
					
						
							|  |  |  | 	MessageQueue* getInputMessageQueue() { return m_basebandSampleSource->getInputMessageQueue(); }   //!< Return pointer to sample source's input message queue
 | 
					
						
							|  |  |  | 	MessageQueue* getOutputMessageQueue() { return m_basebandSampleSource->getOutputMessageQueue(); } //!< Return pointer to sample source's output message queue
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void start(); //!< this thread start()
 | 
					
						
							|  |  |  | 	void stop();  //!< this thread exit() and wait()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool handleSourceMessage(const Message& cmd);  //!< Send message to source synchronously
 | 
					
						
							|  |  |  | 	void pull(Sample& sample);                     //!< Pull one sample from source
 | 
					
						
							| 
									
										
										
										
											2016-12-26 12:11:51 +01:00
										 |  |  | 	void pullAudio(int nbSamples) { if (m_basebandSampleSource) m_basebandSampleSource->pullAudio(nbSamples); } | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-22 23:39:06 +01:00
										 |  |  |     /** direct feeding of sample source FIFO */ | 
					
						
							|  |  |  | 	void feed(SampleSourceFifo* sampleFifo, | 
					
						
							|  |  |  | 		int nbSamples); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-26 12:11:51 +01:00
										 |  |  | 	SampleSourceFifo& getSampleSourceFifo() { return m_basebandSampleSource->getSampleSourceFifo(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 	QString getSampleSourceObjectName() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	QThread *m_thread; //!< The thead object
 | 
					
						
							|  |  |  | 	BasebandSampleSource* m_basebandSampleSource; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* SDRBASE_DSP_THREADEDBASEBANDSAMPLESOURCE_H_ */
 |