-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
BoxAudioBuffer.h
49 lines (35 loc) · 1.05 KB
/
BoxAudioBuffer.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
#ifndef BoxAudioBuffer_h
#define BoxAudioBuffer_h
#include "BaseHeader.h"
class BoxAudioBuffer {
public:
bool noIRQ = false;
void init(uint8_t* buffer, uint16_t size);
void logState();
bool readPointerEqualsWritePointer();
bool
isEmpty(uint16_t threshold = 0),
isFull(uint16_t threshold = 0);
uint8_t* getReadPointer();
void updateReadPointer(uint16_t readLength);
void write(uint8_t* buffer, uint16_t size);
uint16_t
getBytesReadable(),
getBytesReadableBlock(),
getBytesWritable(),
getBytesWritableBlock();
private:
bool _ready = false;
bool
_isFull,
_isEmpty;
uint8_t* _bufferStart;
uint8_t* _bufferEnd;
uint16_t _bufferSize;
uint8_t* _readPointer;
uint8_t* _writePointer;
uint16_t
_measureDistance(uint8_t* p1, uint8_t* p2),
_measureDistanceBlock(uint8_t* p1, uint8_t* p2);
};
#endif