Audacity 3.2.0
FifoBuffer.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FifoBuffer.h
6
7 Dmitry Vedenko
8
9**********************************************************************/
10
11#pragma once
12
13#include <cstdint>
14#include <deque>
15#include <queue>
16
17class FFMPEG_SUPPORT_API FifoBuffer final
18{
19public:
20 explicit FifoBuffer(int pageSize);
21
22 int64_t Write(const void* data, int64_t size);
23 int64_t Read(void* data, int64_t size);
24
25 int64_t GetAvailable() const;
26
27private:
28 struct Page final
29 {
30 explicit Page(int size);
31
32 void Reset();
33
34 std::vector<char> Data;
35 int WritePosition {};
36 int ReadPosition {};
37 };
38
39 std::deque<Page> mAllocatedPages;
40
41 std::queue<Page*> mActivePages;
42 std::deque<Page*> mFreePages;
43
44 int64_t mAvaliable {};
45 const int mPageSize {};
46};
std::deque< Page * > mFreePages
Definition: FifoBuffer.h:42
std::queue< Page * > mActivePages
Definition: FifoBuffer.h:41
std::deque< Page > mAllocatedPages
Definition: FifoBuffer.h:39
std::vector< char > Data
Definition: FifoBuffer.h:34