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
28namespace Titanic {
29
30#define AUDIO_SAMPLING_RATE 22050
31
33private:
34 Common::Mutex _mutex;
36private:
40 void enterCriticalSection();
41
45 void leaveCriticalSection();
46private:
47 bool _finished;
48public:
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 */
Definition: mutex.h:67
Definition: audio_buffer.h:32
int freeSize() const
Definition: audio_buffer.h:69
int size() const
Definition: audio_buffer.h:64
void push(const int16 *values, int count)
void finalize()
Definition: audio_buffer.h:104
void push(int16 value)
int read(int16 *values, int count)
bool isFinished() const
Definition: audio_buffer.h:79
bool empty() const
Definition: audio_buffer.h:59
bool full() const
Definition: audio_buffer.h:74
Definition: fixed_queue.h:34
bool empty() const
Definition: fixed_queue.h:57
size_type freeSize() const
Definition: fixed_queue.h:52
size_type size() const
Definition: fixed_queue.h:47
bool full() const
Definition: fixed_queue.h:64