webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Functions
pa_ringbuffer.c File Reference
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "webrtc/modules/audio_device/mac/portaudio/pa_memorybarrier.h"
#include "webrtc/modules/audio_device/mac/portaudio/pa_ringbuffer.h"

Functions

PaRingBufferSize PaUtil_InitializeRingBuffer (PaUtilRingBuffer *rbuf, PaRingBufferSize elementSizeBytes, PaRingBufferSize elementCount, void *dataPtr)
 
PaRingBufferSize PaUtil_GetRingBufferReadAvailable (PaUtilRingBuffer *rbuf)
 
PaRingBufferSize PaUtil_GetRingBufferWriteAvailable (PaUtilRingBuffer *rbuf)
 
void PaUtil_FlushRingBuffer (PaUtilRingBuffer *rbuf)
 
PaRingBufferSize PaUtil_GetRingBufferWriteRegions (PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount, void **dataPtr1, PaRingBufferSize *sizePtr1, void **dataPtr2, PaRingBufferSize *sizePtr2)
 
PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex (PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount)
 
PaRingBufferSize PaUtil_GetRingBufferReadRegions (PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount, void **dataPtr1, PaRingBufferSize *sizePtr1, void **dataPtr2, PaRingBufferSize *sizePtr2)
 
PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex (PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount)
 
PaRingBufferSize PaUtil_WriteRingBuffer (PaUtilRingBuffer *rbuf, const void *data, PaRingBufferSize elementCount)
 
PaRingBufferSize PaUtil_ReadRingBuffer (PaUtilRingBuffer *rbuf, void *data, PaRingBufferSize elementCount)
 

Function Documentation

◆ PaUtil_AdvanceRingBufferReadIndex()

PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex ( PaUtilRingBuffer rbuf,
PaRingBufferSize  elementCount 
)

Advance the read index to the next location to be read.

Parameters
rbufThe ring buffer.
elementCountThe number of elements to advance.
Returns
The new position.

◆ PaUtil_AdvanceRingBufferWriteIndex()

PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex ( PaUtilRingBuffer rbuf,
PaRingBufferSize  elementCount 
)

Advance the write index to the next location to be written.

Parameters
rbufThe ring buffer.
elementCountThe number of elements to advance.
Returns
The new position.

◆ PaUtil_FlushRingBuffer()

void PaUtil_FlushRingBuffer ( PaUtilRingBuffer rbuf)

Clear buffer. Should only be called when buffer is NOT being read.

Parameters
rbufThe ring buffer.

◆ PaUtil_GetRingBufferReadAvailable()

PaRingBufferSize PaUtil_GetRingBufferReadAvailable ( PaUtilRingBuffer rbuf)

Retrieve the number of elements available in the ring buffer for reading.

Parameters
rbufThe ring buffer.
Returns
The number of elements available for reading.

◆ PaUtil_GetRingBufferReadRegions()

PaRingBufferSize PaUtil_GetRingBufferReadRegions ( PaUtilRingBuffer rbuf,
PaRingBufferSize  elementCount,
void **  dataPtr1,
PaRingBufferSize sizePtr1,
void **  dataPtr2,
PaRingBufferSize sizePtr2 
)

Get address of region(s) from which we can write data.

Parameters
rbufThe ring buffer.
elementCountThe number of elements desired.
dataPtr1The address where the first (or only) region pointer will be stored.
sizePtr1The address where the first (or only) region length will be stored.
dataPtr2The address where the second region pointer will be stored if the first region is too small to satisfy elementCount.
sizePtr2The address where the second region length will be stored if the first region is too small to satisfy elementCount.
Returns
The number of elements available for reading.

◆ PaUtil_GetRingBufferWriteAvailable()

PaRingBufferSize PaUtil_GetRingBufferWriteAvailable ( PaUtilRingBuffer rbuf)

Retrieve the number of elements available in the ring buffer for writing.

Parameters
rbufThe ring buffer.
Returns
The number of elements available for writing.

◆ PaUtil_GetRingBufferWriteRegions()

PaRingBufferSize PaUtil_GetRingBufferWriteRegions ( PaUtilRingBuffer rbuf,
PaRingBufferSize  elementCount,
void **  dataPtr1,
PaRingBufferSize sizePtr1,
void **  dataPtr2,
PaRingBufferSize sizePtr2 
)

Get address of region(s) to which we can write data.

Parameters
rbufThe ring buffer.
elementCountThe number of elements desired.
dataPtr1The address where the first (or only) region pointer will be stored.
sizePtr1The address where the first (or only) region length will be stored.
dataPtr2The address where the second region pointer will be stored if the first region is too small to satisfy elementCount.
sizePtr2The address where the second region length will be stored if the first region is too small to satisfy elementCount.
Returns
The room available to be written or elementCount, whichever is smaller.

◆ PaUtil_InitializeRingBuffer()

PaRingBufferSize PaUtil_InitializeRingBuffer ( PaUtilRingBuffer rbuf,
PaRingBufferSize  elementSizeBytes,
PaRingBufferSize  elementCount,
void dataPtr 
)

Initialize Ring Buffer.

Parameters
rbufThe ring buffer.
elementSizeBytesThe size of a single data element in bytes.
elementCountThe number of elements in the buffer (must be power of 2).
dataPtrA pointer to a previously allocated area where the data will be maintained. It must be elementCount*elementSizeBytes long.
Returns
-1 if elementCount is not a power of 2, otherwise 0.

◆ PaUtil_ReadRingBuffer()

PaRingBufferSize PaUtil_ReadRingBuffer ( PaUtilRingBuffer rbuf,
void data,
PaRingBufferSize  elementCount 
)

Read data from the ring buffer.

Parameters
rbufThe ring buffer.
dataThe address where the data should be stored.
elementCountThe number of elements to be read.
Returns
The number of elements read.

◆ PaUtil_WriteRingBuffer()

PaRingBufferSize PaUtil_WriteRingBuffer ( PaUtilRingBuffer rbuf,
const void data,
PaRingBufferSize  elementCount 
)

Write data to the ring buffer.

Parameters
rbufThe ring buffer.
dataThe address of new data to write to the buffer.
elementCountThe number of elements to be written.
Returns
The number of elements written.