#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"
|
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) |
|
◆ PaUtil_AdvanceRingBufferReadIndex()
Advance the read index to the next location to be read.
- Parameters
-
rbuf | The ring buffer. |
elementCount | The number of elements to advance. |
- Returns
- The new position.
◆ PaUtil_AdvanceRingBufferWriteIndex()
Advance the write index to the next location to be written.
- Parameters
-
rbuf | The ring buffer. |
elementCount | The number of elements to advance. |
- Returns
- The new position.
◆ PaUtil_FlushRingBuffer()
Clear buffer. Should only be called when buffer is NOT being read.
- Parameters
-
◆ PaUtil_GetRingBufferReadAvailable()
Retrieve the number of elements available in the ring buffer for reading.
- Parameters
-
- Returns
- The number of elements available for reading.
◆ PaUtil_GetRingBufferReadRegions()
Get address of region(s) from which we can write data.
- Parameters
-
rbuf | The ring buffer. |
elementCount | The number of elements desired. |
dataPtr1 | The address where the first (or only) region pointer will be stored. |
sizePtr1 | The address where the first (or only) region length will be stored. |
dataPtr2 | The address where the second region pointer will be stored if the first region is too small to satisfy elementCount. |
sizePtr2 | The 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()
Retrieve the number of elements available in the ring buffer for writing.
- Parameters
-
- Returns
- The number of elements available for writing.
◆ PaUtil_GetRingBufferWriteRegions()
Get address of region(s) to which we can write data.
- Parameters
-
rbuf | The ring buffer. |
elementCount | The number of elements desired. |
dataPtr1 | The address where the first (or only) region pointer will be stored. |
sizePtr1 | The address where the first (or only) region length will be stored. |
dataPtr2 | The address where the second region pointer will be stored if the first region is too small to satisfy elementCount. |
sizePtr2 | The 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()
Initialize Ring Buffer.
- Parameters
-
rbuf | The ring buffer. |
elementSizeBytes | The size of a single data element in bytes. |
elementCount | The number of elements in the buffer (must be power of 2). |
dataPtr | A 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()
Read data from the ring buffer.
- Parameters
-
rbuf | The ring buffer. |
data | The address where the data should be stored. |
elementCount | The number of elements to be read. |
- Returns
- The number of elements read.
◆ PaUtil_WriteRingBuffer()
Write data to the ring buffer.
- Parameters
-
rbuf | The ring buffer. |
data | The address of new data to write to the buffer. |
elementCount | The number of elements to be written. |
- Returns
- The number of elements written.