kwave  18.07.70
SampleBuffer.h
Go to the documentation of this file.
1 /*************************************************************************
2  SampleBuffer.h - simple buffer for sample arrays
3  -------------------
4  begin : Sun Oct 17 2010
5  copyright : (C) 2010 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef SAMPLE_BUFFER_H
19 #define SAMPLE_BUFFER_H
20 
21 #include "config.h"
22 
23 #include <QObject>
24 #include <QSemaphore>
25 
26 #include "libkwave/SampleArray.h"
27 #include "libkwave/SampleSink.h"
28 
29 //***************************************************************************
30 namespace Kwave
31 {
32 
33  class Q_DECL_EXPORT SampleBuffer: public Kwave::SampleSink
34  {
35  Q_OBJECT
36  public:
37 
42  SampleBuffer(QObject *parent = Q_NULLPTR);
43 
45  virtual ~SampleBuffer();
46 
48  virtual bool isEmpty() const;
49 
51  virtual Kwave::SampleArray &data();
52 
54  virtual const Kwave::SampleArray &constData() const;
55 
57  virtual unsigned int available() const;
58 
65  virtual const sample_t *get(unsigned int len);
66 
73  void put(sample_t sample);
74 
76  virtual void finished();
77 
78  public slots:
79 
81  virtual void input(Kwave::SampleArray data);
82 
83  protected:
84 
85  friend class BufferJob;
86 
91  void emitData(Kwave::SampleArray data);
92 
93  private:
94 
96  void enqueue(Kwave::SampleArray data);
97 
98  signals:
99 
101  void output(Kwave::SampleArray data);
102 
103  private:
104 
107 
109  unsigned int m_offset;
110 
112  unsigned int m_buffered;
113 
115  QSemaphore m_sema;
116  };
117 
118 }
119 
120 #endif /* SAMPLE_BUFFER_H */
121 
122 //***************************************************************************
123 //***************************************************************************
Definition: App.h:33
unsigned int m_buffered
Definition: SampleBuffer.h:112
Kwave::SampleArray m_data
Definition: SampleBuffer.h:106
qint32 sample_t
Definition: Sample.h:37
unsigned int m_offset
Definition: SampleBuffer.h:109