Oboe
A library for creating real-time audio apps on Android
Loading...
Searching...
No Matches
Public Member Functions | List of all members
oboe::FifoBuffer Class Reference

Public Member Functions

 FifoBuffer (uint32_t bytesPerFrame, uint32_t capacityInFrames)
 
 FifoBuffer (uint32_t bytesPerFrame, uint32_t capacityInFrames, std::atomic< uint64_t > *readCounterAddress, std::atomic< uint64_t > *writeCounterAddress, uint8_t *dataStorageAddress)
 
int32_t convertFramesToBytes (int32_t frames)
 
int32_t read (void *destination, int32_t framesToRead)
 
int32_t write (const void *source, int32_t framesToWrite)
 
uint32_t getBufferCapacityInFrames () const
 
int32_t readNow (void *destination, int32_t numFrames)
 
uint32_t getFullFramesAvailable ()
 
uint32_t getBytesPerFrame () const
 
uint64_t getReadCounter () const
 
void setReadCounter (uint64_t n)
 
uint64_t getWriteCounter ()
 
void setWriteCounter (uint64_t n)
 

Constructor & Destructor Documentation

◆ FifoBuffer() [1/2]

oboe::FifoBuffer::FifoBuffer ( uint32_t  bytesPerFrame,
uint32_t  capacityInFrames 
)

Construct a FifoBuffer.

Parameters
bytesPerFrameamount of bytes for one frame
capacityInFramesthe capacity of frames in fifo

◆ FifoBuffer() [2/2]

oboe::FifoBuffer::FifoBuffer ( uint32_t  bytesPerFrame,
uint32_t  capacityInFrames,
std::atomic< uint64_t > *  readCounterAddress,
std::atomic< uint64_t > *  writeCounterAddress,
uint8_t dataStorageAddress 
)

Construct a FifoBuffer. To be used if the storage allocation is done outside of FifoBuffer.

Parameters
bytesPerFrameamount of bytes for one frame
capacityInFramescapacity of frames in fifo
readCounterAddressaddress of read counter
writeCounterAddressaddress of write counter
dataStorageAddressaddress of storage

Member Function Documentation

◆ convertFramesToBytes()

int32_t oboe::FifoBuffer::convertFramesToBytes ( int32_t  frames)

Convert a number of frames in bytes.

Returns
number of bytes

◆ getBufferCapacityInFrames()

uint32_t oboe::FifoBuffer::getBufferCapacityInFrames ( ) const

Get the buffer capacity in frames.

Returns
number of frames

◆ getBytesPerFrame()

uint32_t oboe::FifoBuffer::getBytesPerFrame ( ) const
inline

Get the amount of bytes per frame.

Returns
number of bytes per frame

◆ getFullFramesAvailable()

uint32_t oboe::FifoBuffer::getFullFramesAvailable ( )
inline

Get the number of frames in the fifo.

Returns
number of frames actually in the buffer

◆ getReadCounter()

uint64_t oboe::FifoBuffer::getReadCounter ( ) const
inline

Get the position of read counter.

Returns
position of read counter

◆ getWriteCounter()

uint64_t oboe::FifoBuffer::getWriteCounter ( )
inline

Get the position of write counter.

Returns
position of write counter

◆ read()

int32_t oboe::FifoBuffer::read ( void destination,
int32_t  framesToRead 
)

Read framesToRead or, if not enough, then read as many as are available.

Parameters
destination
framesToReadnumber of frames requested
Returns
number of frames actually read

◆ readNow()

int32_t oboe::FifoBuffer::readNow ( void destination,
int32_t  numFrames 
)

Calls read(). If all of the frames cannot be read then the remainder of the buffer is set to zero.

Parameters
destination
framesToReadnumber of frames requested
Returns
number of frames actually read

◆ setReadCounter()

void oboe::FifoBuffer::setReadCounter ( uint64_t  n)
inline

Set the position of read counter.

Parameters
nposition of read counter

◆ setWriteCounter()

void oboe::FifoBuffer::setWriteCounter ( uint64_t  n)
inline

Set the position of write counter.

Parameters
nposition of write counter

◆ write()

int32_t oboe::FifoBuffer::write ( const void source,
int32_t  framesToWrite 
)

Write framesToWrite or, if too enough, then write as many as the fifo are not empty.

Parameters
destination
framesToWritenumber of frames requested
Returns
number of frames actually write

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