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.
audiofifo.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_AUDIOFIFO_H
20 #define INCLUDE_AUDIOFIFO_H
21 
22 #include <QObject>
23 #include <QMutex>
24 #include <QWaitCondition>
25 
26 #include "dsp/dsptypes.h"
27 #include "export.h"
28 
29 class SDRBASE_API AudioFifo : public QObject {
30  Q_OBJECT
31 public:
32  AudioFifo();
33  AudioFifo(uint32_t numSamples);
34  ~AudioFifo();
35 
36  bool setSize(uint32_t numSamples);
37 
38  uint32_t write(const quint8* data, uint32_t numSamples);
39  uint32_t read(quint8* data, uint32_t numSamples);
40 
41  uint32_t drain(uint32_t numSamples);
42  void clear();
43 
44  inline uint32_t flush() { return drain(m_fill); }
45  inline uint32_t fill() const { return m_fill; }
46  inline bool isEmpty() const { return m_fill == 0; }
47  inline bool isFull() const { return m_fill == m_size; }
48  inline uint32_t size() const { return m_size; }
49 
50 private:
51  QMutex m_mutex;
52 
53  qint8* m_fifo;
54 
56 
61 
62  bool create(uint32_t numSamples);
63 };
64 
65 #endif // INCLUDE_AUDIOFIFO_H
QMutex m_mutex
Definition: audiofifo.h:51
uint32_t m_tail
Definition: audiofifo.h:60
uint32_t size() const
Definition: audiofifo.h:48
uint32_t flush()
Definition: audiofifo.h:44
uint32_t m_fill
Definition: audiofifo.h:58
uint32_t m_size
Definition: audiofifo.h:57
unsigned int uint32_t
Definition: rtptypes_win.h:46
qint8 * m_fifo
Definition: audiofifo.h:53
void * create(QString type)
uint32_t m_head
Definition: audiofifo.h:59
const uint32_t m_sampleSize
Definition: audiofifo.h:55
bool isEmpty() const
Definition: audiofifo.h:46
bool isFull() const
Definition: audiofifo.h:47
#define SDRBASE_API
Definition: export.h:40
uint32_t fill() const
Definition: audiofifo.h:45