xbmc
Public Member Functions | List of all members
AERingBuffer Class Reference

This buffer can be used by one read and one write thread at any one time without the risk of data corruption. More...

#include <AERingBuffer.h>

Public Member Functions

 AERingBuffer (unsigned int size, unsigned int planes=1)
 
bool Create (int size, unsigned int planes=1)
 Allocates space for buffer, and sets it's contents to 0. More...
 
void Reset ()
 Fills the buffer with zeros and resets the pointers. More...
 
int Write (unsigned char *src, unsigned int size, unsigned int plane=0)
 Writes data to buffer. More...
 
int Read (unsigned char *dest, unsigned int size, unsigned int plane=0)
 Reads data from buffer. More...
 
void Dump ()
 Dumps the buffer.
 
unsigned int GetWriteSize ()
 Returns available space for writing to buffer. More...
 
unsigned int GetReadSize ()
 Returns available space for reading from buffer. More...
 
unsigned int GetMaxSize ()
 Returns the buffer size.
 
unsigned int NumPlanes () const
 Returns the number of planes.
 

Detailed Description

This buffer can be used by one read and one write thread at any one time without the risk of data corruption.

If you intend to call the Reset() method, please use Locks. All other operations are thread-safe.

Member Function Documentation

◆ Create()

bool AERingBuffer::Create ( int  size,
unsigned int  planes = 1 
)
inline

Allocates space for buffer, and sets it's contents to 0.

Returns
true on success, false otherwise

◆ GetReadSize()

unsigned int AERingBuffer::GetReadSize ( )
inline

Returns available space for reading from buffer.

Attempt to read more bytes than available results in AE_RING_BUFFER_EMPTY.

◆ GetWriteSize()

unsigned int AERingBuffer::GetWriteSize ( )
inline

Returns available space for writing to buffer.

Attempt to write more bytes than available results in AE_RING_BUFFER_FULL.

◆ Read()

int AERingBuffer::Read ( unsigned char *  dest,
unsigned int  size,
unsigned int  plane = 0 
)
inline

Reads data from buffer.

Attempt to read more bytes than available results in RING_BUFFER_NOTAVAILABLE. Reading from empty buffer returns AE_RING_BUFFER_EMPTY

Returns
AE_RING_BUFFER_OK on success, otherwise an error code

◆ Reset()

void AERingBuffer::Reset ( )
inline

Fills the buffer with zeros and resets the pointers.

This method is not thread-safe, so before using this method please acquire a Lock()

◆ Write()

int AERingBuffer::Write ( unsigned char *  src,
unsigned int  size,
unsigned int  plane = 0 
)
inline

Writes data to buffer.

Attempt to write more bytes than available results in AE_RING_BUFFER_FULL.

Returns
AE_RING_BUFFER_OK on success, otherwise an error code

The documentation for this class was generated from the following file: