ScummVM API documentation
audio_buffer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_AUDIO_BUFFER_H
23 #define TITANIC_AUDIO_BUFFER_H
24 
25 #include "titanic/support/fixed_queue.h"
26 #include "common/mutex.h"
27 
28 namespace Titanic {
29 
30 #define AUDIO_SAMPLING_RATE 22050
31 
32 class CAudioBuffer {
33 private:
34  Common::Mutex _mutex;
36 private:
40  void enterCriticalSection();
41 
45  void leaveCriticalSection();
46 private:
47  bool _finished;
48 public:
49  CAudioBuffer(int maxSize);
50 
54  void reset();
55 
59  bool empty() const { return _data.empty(); }
60 
64  int size() const { return _data.size(); }
65 
69  int freeSize() const { return _data.freeSize(); }
70 
74  bool full() const { return _data.full(); }
75 
79  bool isFinished() const { return _finished && empty(); }
80 
84  void push(int16 value);
85 
89  void push(const int16 *values, int count);
90 
94  int16 pop();
95 
99  int read(int16 *values, int count);
100 
104  void finalize() { _finished = true; }
105 };
106 
107 } // End of namespace Titanic
108 
109 #endif /* TITANIC_AUDIO_BUFFER_H */
bool empty() const
Definition: audio_buffer.h:59
int size() const
Definition: audio_buffer.h:64
bool full() const
Definition: audio_buffer.h:74
Definition: audio_buffer.h:32
size_type freeSize() const
Definition: fixed_queue.h:52
bool full() const
Definition: fixed_queue.h:64
size_type size() const
Definition: fixed_queue.h:47
int read(int16 *values, int count)
void push(int16 value)
Definition: mutex.h:67
Definition: arm.h:30
bool isFinished() const
Definition: audio_buffer.h:79
int freeSize() const
Definition: audio_buffer.h:69
bool empty() const
Definition: fixed_queue.h:57
Definition: fixed_queue.h:34
void finalize()
Definition: audio_buffer.h:104