7#include "libxr_assert.hpp"
8#include "libxr_type.hpp"
78 uint8_t*
Buffer(
int block)
const;
125 bool FillActive(
const uint8_t* data,
size_t len);
188 uint8_t* buffer_[2] = {
nullptr,
nullptr};
191 bool pending_valid_ =
193 size_t active_len_ = 0;
194 size_t pending_len_ = 0;
双缓冲区管理类 / Double buffer manager class
void SetActiveLength(size_t length)
设置当前活动缓冲区的数据长度 Sets the size of the active buffer
DoubleBuffer()=default
默认构造一个未初始化的双缓冲对象 Constructs one uninitialized double buffer object
int ActiveBlock() const
获取当前活动缓冲区编号 Returns the current active block index
void SetActiveBlock(bool block)
设置当前活动缓冲区 Sets the active buffer
void Reset()
重置 active/pending 状态,但保留已绑定的 backing storage Resets active/pending state while keeping bound backing ...
void SetPendingLength(size_t length)
设置备用缓冲区的数据长度 Sets the size of the pending buffer
void EnablePending()
手动启用 pending 状态 Manually sets the pending state to true
bool HasPending() const
判断是否有待切换的缓冲区 Checks whether a pending buffer is ready
void FlipActiveBlock()
翻转当前活动缓冲区编号 Flips the current active block index
size_t Size() const
获取每个缓冲区的大小(单位:字节) Gets the size of each buffer in bytes
uint8_t * Buffer(int block) const
获取指定编号缓冲区的指针 Returns the pointer of the specified block
bool FillActive(const uint8_t *data, size_t len)
向当前使用的缓冲区直接写入数据 Fills the active buffer directly
uint8_t * ActiveBuffer() const
获取当前正在使用的缓冲区指针 Returns the currently active buffer
size_t GetActiveLength() const
获取当前活动缓冲区中准备好的数据长度 Gets the size of valid data in active buffer
void Init(const LibXR::RawData &raw_data)
绑定连续 backing storage 并重置双缓冲状态 Binds continuous backing storage and resets double-buffer state
uint8_t * PendingBuffer() const
获取备用缓冲区的指针 Returns the pending (inactive) buffer
void Switch()
切换到备用缓冲区(若其有效) Switches to the pending buffer if it's valid
size_t GetPendingLength() const
获取 pending 缓冲区中准备好的数据长度 Gets the size of valid data in pending buffer
bool FillPending(const uint8_t *data, size_t len)
向备用缓冲区写入数据(不可重入) Fills the pending buffer with data (non-reentrant)
可写原始数据视图 / Mutable raw data view
LibXR 命名空间 / LibXR namespace.