SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
samplesinkfifo.h
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // written by Christian Daniel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef INCLUDE_SAMPLEFIFO_H
20 #define INCLUDE_SAMPLEFIFO_H
21 
22 #include <QObject>
23 #include <QMutex>
24 #include <QTime>
25 #include "dsp/dsptypes.h"
26 #include "export.h"
27 
28 class SDRBASE_API SampleSinkFifo : public QObject {
29  Q_OBJECT
30 
31 private:
32  QMutex m_mutex;
35 
37 
38  uint m_size;
39  uint m_fill;
40  uint m_head;
41  uint m_tail;
42 
43  void create(uint s);
44 
45 public:
46  SampleSinkFifo(QObject* parent = nullptr);
47  SampleSinkFifo(int size, QObject* parent = nullptr);
48  SampleSinkFifo(const SampleSinkFifo& other);
49  ~SampleSinkFifo();
50 
51  bool setSize(int size);
52  inline uint size() const { return m_size; }
53  inline uint fill() { QMutexLocker mutexLocker(&m_mutex); uint fill = m_fill; return fill; }
54 
55  uint write(const quint8* data, uint count);
56  uint write(SampleVector::const_iterator begin, SampleVector::const_iterator end);
57 
58  uint read(SampleVector::iterator begin, SampleVector::iterator end);
59 
60  uint readBegin(uint count,
61  SampleVector::iterator* part1Begin, SampleVector::iterator* part1End,
62  SampleVector::iterator* part2Begin, SampleVector::iterator* part2End);
63  uint readCommit(uint count);
64 
65 signals:
66  void dataReady();
67 };
68 
69 #endif // INCLUDE_SAMPLEFIFO_H
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
SampleVector m_data
void * create(QString type)
uint size() const
#define SDRBASE_API
Definition: export.h:40