| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 INCLUDE_SAMPLEFIFO_H
 | 
					
						
							|  |  |  | #define INCLUDE_SAMPLEFIFO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QMutex>
 | 
					
						
							|  |  |  | #include <QTime>
 | 
					
						
							|  |  |  | #include "dsp/dsptypes.h"
 | 
					
						
							|  |  |  | #include "util/export.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 01:26:51 +02:00
										 |  |  | class SDRANGEL_API SampleFifo : public QObject { | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	QMutex m_mutex; | 
					
						
							|  |  |  | 	QTime m_msgRateTimer; | 
					
						
							|  |  |  | 	int m_suppressed; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	SampleVector m_data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint m_size; | 
					
						
							|  |  |  | 	uint m_fill; | 
					
						
							|  |  |  | 	uint m_head; | 
					
						
							|  |  |  | 	uint m_tail; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void create(uint s); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	SampleFifo(QObject* parent = NULL); | 
					
						
							|  |  |  | 	SampleFifo(int size, QObject* parent = NULL); | 
					
						
							|  |  |  | 	~SampleFifo(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool setSize(int size); | 
					
						
							| 
									
										
										
										
											2015-08-04 23:45:32 +02:00
										 |  |  | 	inline uint size() const { return m_size; } | 
					
						
							| 
									
										
										
										
											2015-10-21 02:32:21 +02:00
										 |  |  | 	inline uint fill() { QMutexLocker mutexLocker(&m_mutex); uint fill = m_fill; return fill; } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	uint write(const quint8* data, uint count); | 
					
						
							|  |  |  | 	uint write(SampleVector::const_iterator begin, SampleVector::const_iterator end); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint read(SampleVector::iterator begin, SampleVector::iterator end); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	uint readBegin(uint count, | 
					
						
							|  |  |  | 		SampleVector::iterator* part1Begin, SampleVector::iterator* part1End, | 
					
						
							|  |  |  | 		SampleVector::iterator* part2Begin, SampleVector::iterator* part2End); | 
					
						
							|  |  |  | 	uint readCommit(uint count); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  | 	void dataReady(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_SAMPLEFIFO_H
 |