Home --> Documentations --> PJMEDIA Reference
Circular buffer manages read and write contiguous audio samples in a non-contiguous buffer as if the buffer were contiguous. This should give better performance than keeping contiguous samples in a contiguous buffer, since read/write operations will only update the pointers, instead of shifting audio samples.
More...
|
#define | PJMEDIA_CIRC_BUF_CHECK(x) |
|
|
pj_status_t | pjmedia_circ_buf_create (pj_pool_t *pool, unsigned capacity, pjmedia_circ_buf **p_cb) |
|
pj_status_t | pjmedia_circ_buf_reset (pjmedia_circ_buf *circbuf) |
|
unsigned | pjmedia_circ_buf_get_len (pjmedia_circ_buf *circbuf) |
|
void | pjmedia_circ_buf_set_len (pjmedia_circ_buf *circbuf, unsigned len) |
|
pj_status_t | pjmedia_circ_buf_adv_read_ptr (pjmedia_circ_buf *circbuf, unsigned count) |
|
pj_status_t | pjmedia_circ_buf_adv_write_ptr (pjmedia_circ_buf *circbuf, unsigned count) |
|
void | pjmedia_circ_buf_get_read_regions (pjmedia_circ_buf *circbuf, pj_int16_t **reg1, unsigned *reg1_len, pj_int16_t **reg2, unsigned *reg2_len) |
|
void | pjmedia_circ_buf_get_write_regions (pjmedia_circ_buf *circbuf, pj_int16_t **reg1, unsigned *reg1_len, pj_int16_t **reg2, unsigned *reg2_len) |
|
pj_status_t | pjmedia_circ_buf_read (pjmedia_circ_buf *circbuf, pj_int16_t *data, unsigned count) |
|
pj_status_t | pjmedia_circ_buf_write (pjmedia_circ_buf *circbuf, pj_int16_t *data, unsigned count) |
|
pj_status_t | pjmedia_circ_buf_copy (pjmedia_circ_buf *circbuf, unsigned start_idx, pj_int16_t *data, unsigned count) |
|
pj_status_t | pjmedia_circ_buf_pack_buffer (pjmedia_circ_buf *circbuf) |
|
This section describes PJMEDIA's implementation of circular buffer.
◆ pjmedia_circ_buf_create()
◆ pjmedia_circ_buf_reset()
◆ pjmedia_circ_buf_get_len()
◆ pjmedia_circ_buf_set_len()
Set circular buffer length. This is useful when audio buffer is manually manipulated by the user, e.g: shrinked, expanded.
- Parameters
-
circbuf | The circular buffer. |
len | The new buffer length. |
References PJ_INLINE.
◆ pjmedia_circ_buf_adv_read_ptr()
Advance the read pointer of circular buffer. This function will discard the skipped samples while advancing the read pointer, thus reducing the buffer length.
- Parameters
-
circbuf | The circular buffer. |
count | Distance from current read pointer, can only be possitive number, in samples. |
- Returns
- PJ_SUCCESS when successful, otherwise the appropriate error will be returned.
References pjmedia_circ_buf::len, PJ_INLINE, and pjmedia_circ_buf_reset().
Referenced by pjmedia_circ_buf_read().
◆ pjmedia_circ_buf_adv_write_ptr()
Advance the write pointer of circular buffer. Since write pointer is always pointing to a sample after the end of sample, so this function also means increasing the buffer length.
- Parameters
-
circbuf | The circular buffer. |
count | Distance from current write pointer, can only be possitive number, in samples. |
- Returns
- PJ_SUCCESS when successful, otherwise the appropriate error will be returned.
References pjmedia_circ_buf::capacity, pjmedia_circ_buf::len, PJ_ETOOBIG, PJ_INLINE, and PJ_SUCCESS.
Referenced by pjmedia_circ_buf_write().
◆ pjmedia_circ_buf_get_read_regions()
◆ pjmedia_circ_buf_get_write_regions()
◆ pjmedia_circ_buf_read()
◆ pjmedia_circ_buf_write()
◆ pjmedia_circ_buf_copy()
◆ pjmedia_circ_buf_pack_buffer()
Pack the buffer so the first sample will be in the beginning of the buffer. This will also make the buffer contiguous.
- Parameters
-
circbuf | The circular buffer. |
- Returns
- PJ_SUCCESS when successful, otherwise the appropriate error will be returned.
References pjmedia_circ_buf::buf, pjmedia_circ_buf::capacity, PJ_ETOOBIG, PJ_INLINE, PJ_SUCCESS, pjmedia_circ_buf_get_len(), pjmedia_circ_buf_get_read_regions(), pjmedia_copy_samples(), pjmedia_move_samples(), and pjmedia_circ_buf::start.
PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.
|