X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fframe_on_disk.h;h=360bd23ce1222271cfef1f82df5006de0b141a60;hb=e0cb348ca42ae7057f8f5acee92a23e7eb26075f;hp=f74cb86f717161a9b6a9ffab8575594a5a8548b4;hpb=4a9e97065dade428e373a83618bc973cd93cbe52;p=nageru diff --git a/futatabi/frame_on_disk.h b/futatabi/frame_on_disk.h index f74cb86..360bd23 100644 --- a/futatabi/frame_on_disk.h +++ b/futatabi/frame_on_disk.h @@ -14,7 +14,9 @@ struct FrameOnDisk { int64_t pts = -1; // -1 means empty. off_t offset; unsigned filename_idx; - uint32_t size; // Not using size_t saves a few bytes; we can have so many frames. + uint32_t size; // Not using size_t saves a few bytes; we can have so many frames. TODO: Not anymore due to audio_size. + uint32_t audio_size; + // Unfortunately, 32 bits wasted in padding here. }; extern std::vector frames[MAX_STREAMS]; // Under frame_mu. extern std::vector frame_filenames; // Under frame_mu. @@ -24,7 +26,8 @@ static bool inline operator==(const FrameOnDisk &a, const FrameOnDisk &b) return a.pts == b.pts && a.offset == b.offset && a.filename_idx == b.filename_idx && - a.size == b.size; + a.size == b.size && + a.audio_size == b.audio_size; } // A helper class to read frames from disk. It caches the file descriptor @@ -32,11 +35,18 @@ static bool inline operator==(const FrameOnDisk &a, const FrameOnDisk &b) // the sequential reads. (For this reason, each display has a private // FrameReader. Thus, we can easily keep multiple open file descriptors around // for a single .frames file.) +// +// Thread-compatible, but not thread-safe. class FrameReader { public: FrameReader(); ~FrameReader(); - std::string read_frame(FrameOnDisk frame); + + struct Frame { + std::string video; + std::string audio; + }; + Frame read_frame(FrameOnDisk frame, bool read_audio); private: int fd = -1;