xine-lib: xine-lib-1.2.12/src/xine-engine/buffer.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Functions
buffer.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <pthread.h>`
`#include <xine/buffer.h>`
`#include <xine/xineutils.h>`
`#include <xine/xine_internal.h>`
`#include "xine_private.h"`

## Data Structures
struct | be_ei_t

## Macros
#define | LOG_MODULE "buffer"
#define | LOG_VERBOSE
#define | LARGE_NUM 0x7fffffff

## Functions
static void | fbc_dummy (fifo_buffer_t *this, void *data)
int | xine_fbc_set (fifo_buffer_t *fifo, int on)
static int | fbc_avail (fifo_buffer_t *this)
static void | fbc_reset (fifo_buffer_t *this)
static void | fbc_sub (fifo_buffer_t *this, int n)
static void | buffer_pool_free (buf_element_t *element)
static buf_element_t * | buffer_pool_size_alloc_int (fifo_buffer_t *this, int n)
static buf_element_t * | buffer_pool_size_alloc (fifo_buffer_t *this, size_t size)
static buf_element_t * | buffer_pool_alloc (fifo_buffer_t *this)
static buf_element_t * | buffer_pool_realloc (buf_element_t *buf, size_t new_size)
static buf_element_t * | buffer_pool_try_alloc (fifo_buffer_t *this)
static void | fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element)
static void | dummy_fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element)
static void | fifo_buffer_insert (fifo_buffer_t *fifo, buf_element_t *element)
static void | dummy_fifo_buffer_insert (fifo_buffer_t *fifo, buf_element_t *element)
static buf_element_t * | fifo_buffer_get (fifo_buffer_t *fifo)
static buf_element_t * | fifo_buffer_tget (fifo_buffer_t *fifo, xine_ticket_t *ticket)
static void | fifo_buffer_clear (fifo_buffer_t *fifo)
static void | fifo_buffer_all_clear (fifo_buffer_t *fifo)
static int | fifo_buffer_size (fifo_buffer_t *this)
static uint32_t | fifo_buffer_data_size (fifo_buffer_t *this)
static int | fifo_buffer_num_free (fifo_buffer_t *this)
static void | fifo_buffer_dispose (fifo_buffer_t *this)
static void | fifo_register_alloc_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, void *data_cb), void *data_cb)
static void | fifo_register_put_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb), void *data_cb)
static void | fifo_register_get_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb), void *data_cb)
static void | fifo_unregister_alloc_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, void *data_cb))
static void | fifo_unregister_put_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb))
static void | fifo_unregister_get_cb (fifo_buffer_t *this, void(*cb)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb))
fifo_buffer_t * | _x_fifo_buffer_new (int num_buffers, uint32_t buf_size)
| Allocate and initialise new (empty) FIFO buffers. More...
fifo_buffer_t * | _x_dummy_fifo_buffer_new (int num_buffers, uint32_t buf_size)
| Allocate and initialise new dummy FIFO buffers. More...
void | _x_free_buf_elements (buf_element_t *head)
| Free chained list of buffer elements. More...

## Macro Definition Documentation

## ◆ LARGE_NUM

#define LARGE_NUM 0x7fffffff

## ◆ LOG_MODULE

#define LOG_MODULE "buffer"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## Function Documentation

## ◆ _x_dummy_fifo_buffer_new()

fifo_buffer_t * _x_dummy_fifo_buffer_new | ( | int | num_buffers,
|  | uint32_t | buf_size
| ) |  |

Allocate and initialise new dummy FIFO buffers.

Parameters

  num_buffer | Number of dummy buffers to allocate.
  buf_size | Size of each buffer.

Only used by video and audio decoder loops.

References _x_fifo_buffer_new(), dummy_fifo_buffer_insert(), dummy_fifo_buffer_put(), and put.

Referenced by _x_audio_decoder_init(), and _x_video_decoder_init().

## ◆ _x_fifo_buffer_new()

fifo_buffer_t * _x_fifo_buffer_new | ( | int | num_buffers,
|  | uint32_t | buf_size
| ) |  |

Allocate and initialise new (empty) FIFO buffers.

Parameters

  num_buffer | Number of buffers to allocate.
  buf_size | Size of each buffer.

Only used by video and audio decoder loops.

References buffer_pool_alloc(), buffer_pool_free(), buffer_pool_realloc(), buffer_pool_size_alloc(), buffer_pool_try_alloc(), be_ei_t::ei, be_ei_t::elem, buf_element_s::extra_info, fifo_buffer_clear(), fifo_buffer_data_size(), fifo_buffer_dispose(), fifo_buffer_get(), fifo_buffer_insert(), fifo_buffer_num_free(), fifo_buffer_put(), fifo_buffer_size(), fifo_buffer_tget(), fifo_register_alloc_cb(), fifo_register_get_cb(), fifo_register_put_cb(), fifo_unregister_alloc_cb(), fifo_unregister_get_cb(), fifo_unregister_put_cb(), buf_element_s::free_buffer, LARGE_NUM, buf_element_s::max_size, buf_element_s::mem, be_ei_t::nbufs, buf_element_s::next, NULL, put, buf_element_s::source, and xine_mallocz_aligned().

Referenced by _x_audio_decoder_init(), _x_dummy_fifo_buffer_new(), and _x_video_decoder_init().

## ◆ _x_free_buf_elements()

void _x_free_buf_elements | ( | buf_element_t * | head | ) |

Free chained list of buffer elements.

Parameters

  head | List to free. May be NULL.

References buf_element_s::free_buffer, and buf_element_s::next.

Referenced by audio_decoder_loop().

## ◆ buffer_pool_alloc()

static buf_element_t * buffer_pool_alloc | ( | fifo_buffer_t * | this | ) |
| static

References _x_extra_info_reset(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, be_ei_t::elem, buf_element_s::extra_info, fbc_avail(), buf_element_s::max_size, buf_element_s::mem, be_ei_t::nbufs, buf_element_s::next, buf_element_s::pts, and buf_element_s::size.

Referenced by _x_fifo_buffer_new().

## ◆ buffer_pool_free()

static void buffer_pool_free | ( | buf_element_t * | element | ) |
| static

References _, _x_abort, be_ei_t::elem, fbc_avail(), fbc_sub(), be_ei_t::nbufs, buf_element_s::next, and buf_element_s::source.

Referenced by _x_fifo_buffer_new(), buffer_pool_realloc(), fifo_buffer_all_clear(), fifo_buffer_clear(), fifo_buffer_get(), fifo_buffer_insert(), fifo_buffer_put(), and fifo_buffer_tget().

## ◆ buffer_pool_realloc()

static buf_element_t * buffer_pool_realloc | ( | buf_element_t * | buf,
|  | size_t | new_size
| ) |  |
| static

References buffer_pool_free(), buffer_pool_size_alloc_int(), be_ei_t::elem, buf_element_s::free_buffer, buf_element_s::max_size, be_ei_t::nbufs, buf_element_s::next, NULL, and buf_element_s::source.

Referenced by _x_fifo_buffer_new().

## ◆ buffer_pool_size_alloc()

static buf_element_t * buffer_pool_size_alloc | ( | fifo_buffer_t * | this,
|  | size_t | size
| ) |  |
| static

References buffer_pool_size_alloc_int().

Referenced by _x_fifo_buffer_new().

## ◆ buffer_pool_size_alloc_int()

static buf_element_t * buffer_pool_size_alloc_int | ( | fifo_buffer_t * | this,
|  | int | n
| ) |  |
| static

References _x_extra_info_reset(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, be_ei_t::elem, buf_element_s::extra_info, fbc_avail(), LARGE_NUM, buf_element_s::max_size, buf_element_s::mem, be_ei_t::nbufs, buf_element_s::next, buf_element_s::pts, and buf_element_s::size.

Referenced by buffer_pool_realloc(), and buffer_pool_size_alloc().

## ◆ buffer_pool_try_alloc()

static buf_element_t * buffer_pool_try_alloc | ( | fifo_buffer_t * | this | ) |
| static

References _x_extra_info_reset(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, be_ei_t::elem, buf_element_s::extra_info, buf_element_s::max_size, buf_element_s::mem, be_ei_t::nbufs, buf_element_s::next, NULL, buf_element_s::pts, and buf_element_s::size.

Referenced by _x_fifo_buffer_new().

## ◆ dummy_fifo_buffer_insert()

static void dummy_fifo_buffer_insert | ( | fifo_buffer_t * | fifo,
|  | buf_element_t * | element
| ) |  |
| static

References buf_element_s::free_buffer.

Referenced by _x_dummy_fifo_buffer_new().

## ◆ dummy_fifo_buffer_put()

static void dummy_fifo_buffer_put | ( | fifo_buffer_t * | fifo,
|  | buf_element_t * | element
| ) |  |
| static

References buf_element_s::free_buffer, fifo_buffer_s::mutex, fifo_buffer_s::put_cb, and fifo_buffer_s::put_cb_data.

Referenced by _x_dummy_fifo_buffer_new().

## ◆ fbc_avail()

static int fbc_avail | ( | fifo_buffer_t * | this | ) |
| static

References fbc_dummy().

Referenced by buffer_pool_alloc(), buffer_pool_free(), and buffer_pool_size_alloc_int().

## ◆ fbc_dummy()

static void fbc_dummy | ( | fifo_buffer_t * | this,
|  | void * | data
| ) |  |
| static

Referenced by fbc_avail(), fbc_reset(), fbc_sub(), fifo_register_alloc_cb(), and xine_fbc_set().

## ◆ fbc_reset()

static void fbc_reset | ( | fifo_buffer_t * | this | ) |
| static

References fbc_dummy().

Referenced by fifo_buffer_clear().

## ◆ fbc_sub()

static void fbc_sub | ( | fifo_buffer_t * | this,
|  | int | n
| ) |  |
| static

References fbc_dummy().

Referenced by buffer_pool_free().

## ◆ fifo_buffer_all_clear()

static void fifo_buffer_all_clear | ( | fifo_buffer_t * | fifo | ) |
| static

References buffer_pool_free(), be_ei_t::elem, fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::last, fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, NULL, and buf_element_s::source.

Referenced by fifo_buffer_dispose().

## ◆ fifo_buffer_clear()

static void fifo_buffer_clear | ( | fifo_buffer_t * | fifo | ) |
| static

References BUF_CONTROL_BASE, BUF_MAJOR_MASK, buffer_pool_free(), be_ei_t::elem, fbc_reset(), fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::last, fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, NULL, buf_element_s::size, and buf_element_s::type.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_data_size()

static uint32_t fifo_buffer_data_size | ( | fifo_buffer_t * | this | ) |
| static

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_dispose()

static void fifo_buffer_dispose | ( | fifo_buffer_t * | this | ) |
| static

References fifo_buffer_all_clear(), and xine_free_aligned().

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_get()

static buf_element_t * fifo_buffer_get | ( | fifo_buffer_t * | fifo | ) |
| static

References buffer_pool_free(), fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_num_waiters, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::get_cb, fifo_buffer_s::get_cb_data, fifo_buffer_s::last, fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, fifo_buffer_s::not_empty, NULL, and buf_element_s::size.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_insert()

static void fifo_buffer_insert | ( | fifo_buffer_t * | fifo,
|  | buf_element_t * | element
| ) |  |
| static

References buffer_pool_free(), fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_num_waiters, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::last, fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, fifo_buffer_s::not_empty, and buf_element_s::size.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_num_free()

static int fifo_buffer_num_free | ( | fifo_buffer_t * | this | ) |
| static

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_put()

static void fifo_buffer_put | ( | fifo_buffer_t * | fifo,
|  | buf_element_t * | element
| ) |  |
| static

References BUF_FLAG_MERGE, fifo_buffer_s::buffer_pool_capacity, buffer_pool_free(), buf_element_s::decoder_flags, fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_num_waiters, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::last, fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, fifo_buffer_s::not_empty, NULL, fifo_buffer_s::put_cb, fifo_buffer_s::put_cb_data, and buf_element_s::size.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_size()

static int fifo_buffer_size | ( | fifo_buffer_t * | this | ) |
| static

Referenced by _x_fifo_buffer_new().

## ◆ fifo_buffer_tget()

static buf_element_t * fifo_buffer_tget | ( | fifo_buffer_t * | fifo,
|  | xine_ticket_t * | ticket
| ) |  |
| static

References xine_ticket_s::acquire, buffer_pool_free(), fifo_buffer_s::fifo_data_size, fifo_buffer_s::fifo_num_waiters, fifo_buffer_s::fifo_size, fifo_buffer_s::first, buf_element_s::free_buffer, fifo_buffer_s::get_cb, fifo_buffer_s::get_cb_data, fifo_buffer_s::last, mode(), fifo_buffer_s::mutex, be_ei_t::nbufs, buf_element_s::next, fifo_buffer_s::not_empty, NULL, xine_ticket_s::release, buf_element_s::size, and xine_ticket_s::ticket_revoked.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_register_alloc_cb()

static void fifo_register_alloc_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, void *data_cb) | cb,
|  | void * | data_cb
| ) |  |
| static

References BUF_MAX_CALLBACKS, fbc_dummy(), and NULL.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_register_get_cb()

static void fifo_register_get_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb) | cb,
|  | void * | data_cb
| ) |  |
| static

References BUF_MAX_CALLBACKS, and NULL.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_register_put_cb()

static void fifo_register_put_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb) | cb,
|  | void * | data_cb
| ) |  |
| static

References BUF_MAX_CALLBACKS, and NULL.

Referenced by _x_fifo_buffer_new().

## ◆ fifo_unregister_alloc_cb()

static void fifo_unregister_alloc_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, void *data_cb) | cb
| ) |  |
| static

Referenced by _x_fifo_buffer_new().

## ◆ fifo_unregister_get_cb()

static void fifo_unregister_get_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb) | cb
| ) |  |
| static

Referenced by _x_fifo_buffer_new().

## ◆ fifo_unregister_put_cb()

static void fifo_unregister_put_cb | ( | fifo_buffer_t * | this,
|  | void(*)(fifo_buffer_t *this, buf_element_t *buf, void *data_cb) | cb
| ) |  |
| static

Referenced by _x_fifo_buffer_new().

## ◆ xine_fbc_set()

int xine_fbc_set | ( | fifo_buffer_t * | fifo,
|  | int | on
| ) |  |

References fifo_buffer_s::alloc_cb, fifo_buffer_s::alloc_cb_data, fifo_buffer_s::buffer_pool_capacity, fbc_dummy(), fifo_buffer_s::mutex, and NULL.