-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuffer.h
69 lines (57 loc) · 1.92 KB
/
buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/** Buffer
* Copyright (C) Madura A.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include "bufferconfig.h"
#include "stopwatch.h"
class Buffer {
public:
enum class Type : int {
StreamEnd = 0,
StreamStart, // only for new stream starts: not at gapless resume or resume after pause
StreamStop,
StreamPause,
StreamResume,
StreamBuffer
};
private:
BufferConfig _config;
real_t *_buffer;
int _size;
int _id;
Type _type;
StopWatch _watch;
uint64_t _stream_id;
public:
Buffer(BufferConfig &config, int id);
~Buffer();
inline void SetBufferType(Type type) { _type = type; }
inline Type GetBufferType() const { return _type; }
inline BufferConfig *GetBufferConfig() { return &_config; }
void Reset(BufferConfig *config);
inline int GetId() const { return _id; }
inline real_t *GetData() { return _buffer; }
inline StopWatch &GetWatch() { return _watch; }
inline void SetStreamId(uint64_t stream_id) { _stream_id = stream_id; }
inline uint64_t GetStreamId() const { return _stream_id; }
inline void Silence() {
for (int i = 0; i < _size; i++) {
_buffer[i] = (real_t)0.0;
}
}
};