]> git.sesse.net Git - nageru/blob - frame_on_disk.h
Allow symlinked frame files. Useful for testing.
[nageru] / frame_on_disk.h
1 #ifndef _FRAME_ON_DISK_H
2 #define _FRAME_ON_DISK_H 1
3
4 #include <mutex>
5 #include <string>
6 #include <vector>
7
8 #include <stdint.h>
9
10 #include "defs.h"
11
12 extern std::mutex frame_mu;
13 struct FrameOnDisk {
14         int64_t pts = -1;  // -1 means empty.
15         off_t offset;
16         unsigned filename_idx;
17         uint32_t size;  // Not using size_t saves a few bytes; we can have so many frames.
18 };
19 extern std::vector<FrameOnDisk> frames[MAX_STREAMS];  // Under frame_mu.
20 extern std::vector<std::string> frame_filenames;  // Under frame_mu.
21
22 // A helper class to read frames from disk. It caches the file descriptor
23 // so that the kernel has a better chance of doing readahead when it sees
24 // the sequential reads. (For this reason, each display has a private
25 // FrameReader. Thus, we can easily keep multiple open file descriptors around
26 // for a single .frames file.)
27 class FrameReader {
28 public:
29         ~FrameReader();
30         std::string read_frame(FrameOnDisk frame);
31
32 private:
33         int fd = -1;
34         int last_filename_idx = -1;
35 };
36
37 #endif  // !defined(_FRAME_ON_DISK_H)