upipe/ubuf_mem_common.h header reference

Upipe common functions for ubuf managers with umem storage More

Header inclusion  

Members  

Type  

Functions  

Macro  

Description  

Upipe common functions for ubuf managers with umem storage

Members detail  

#define UBUF_MEM_MGR_HELPER_POOL(STRUCTURE, UBUF_POOL, SHARED_POOL, SHARED)  

This macro is declared in upipe/ubuf_mem_common.h source file, line 189.

This macro declares eight functions dealing with the structure pools of ubuf managers using umem storage.

You must add two members to your private ubuf_mgr structure, for instance:

struct upool *ubuf_pool;
struct upool *shared_pool

And one member to your private ubuf structure, for instance:

struct ubuf_mem_shared *shared;

Supposing the name of your structures are respectively ubuf_foo_mgr and ubuf_foo, it declares:

  • struct ubuf_foo *ubuf_foo_alloc_pool(struct ubuf_mgr *)

    Allocates the data structure or fetches it from the pool.

  • struct ubuf_mem_shared *ubuf_foo_shared_alloc_pool(struct ubuf_mgr *)

    Allocates the shared data structure or fetches it from the pool.

  • void ubuf_foo_free_pool(struct ubuf_mgr *, struct ubuf_foo *)

    Deallocates the data structure or places it back into the pool.

  • void ubuf_foo_shared_free_pool(struct ubuf_mgr *, struct ubuf_mem_shared *)

    Deallocates the shared data structure or places it back into the pool.

  • void ubuf_foo_mgr_vacuum_pool(struct ubuf_mgr *)

    Releases all structures kept in pools.

  • void ubuf_foo_mgr_clean_pool(struct ubuf_mgr *)

    Called before deallocation of the manager.

  • size_t ubuf_foo_mgr_sizeof_pool(uint16_t ubuf_pool_depth, uint16_t shared_pool_depth)

    Returns the required size of extra data space for pools.

  • void ubuf_foo_mgr_init_pool(struct ubuf_mgr *, uint16_t ubuf_pool_depth,
    uint16_t shared_pool_depth, void *extra, upool_alloc_cb ubuf_alloc_cb,
    upool_free_cb ubuf_free_cb)

    Called when allocating the manager.

You must also declare such as function prior to using this macro:

struct ubuf_foo_mgr *ubuf_foo_mgr_from_ubuf_mgr(struct ubuf_mgr *mgr)

Parameter list:

  • STRUCTURE: name of your private ubuf structure
  • UBUF_POOL: name of the ubuf pool in your private ubuf_mgr structure
  • SHARED_POOL: name of the shared pool in your private ubuf_mgr structure
  • SHARED: name of the struct ubuf_mem_shared field of your private ubuf structure

#define _UPIPE_UBUF_MEM_COMMON_H_  

This macro is declared in upipe/ubuf_mem_common.h source file, line 31.

struct ubuf_mem_shared  

This struct is declared in upipe/ubuf_mem_common.h source file, line 46.

This struct is the low-level shared structure with reference counting, pointing to the actual data.

FieldDescription
uatomic_uint32_t refcount;number of blocks pointing to the memory area
struct upool * pool;pointer to origin pool
struct umem umem;umem structure pointing to buffer

void * ubuf_mem_shared_alloc_inner(struct upool *upool)  

This function is declared in upipe/ubuf_mem_common.h source file, line 110.

This function allocates the shared data structure.

Parameter list:

  • upool: pointer to upool

The return value is pointer to ubuf_block_mem or NULL in case of allocation error

uint8_t * ubuf_mem_shared_buffer(struct ubuf_mem_shared *shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 92.

This function returns the shared buffer.

Parameter list:

  • shared: pointer to shared buffer

void ubuf_mem_shared_free_inner(struct upool *upool, void *_shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 117.

This function frees a shared data structure.

Parameter list:

  • upool: pointer to upool
  • _shared: pointer to shared structure to free

bool ubuf_mem_shared_release(struct ubuf_mem_shared *shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 73.

This function decrements the reference count of a shared buffer.

Parameter list:

  • shared: pointer to shared buffer

The return value is true if the buffer needs deallocation

bool ubuf_mem_shared_single(struct ubuf_mem_shared *shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 83.

This function checks whether there is only one reference to the shared buffer.

Parameter list:

  • shared: pointer to shared buffer

The return value is true if there is only one reference

size_t ubuf_mem_shared_size(struct ubuf_mem_shared *shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 101.

This function returns the size of the shared buffer.

Parameter list:

  • shared: pointer to shared buffer

struct ubuf_mem_shared * ubuf_mem_shared_use(struct ubuf_mem_shared *shared)  

This function is declared in upipe/ubuf_mem_common.h source file, line 62.

This function increments the reference count of a shared buffer.

Parameter list:

  • shared: pointer to shared buffer

The return value is pointer to shared buffer

Valid XHTML 1.0 StrictGenerated by cmassiot on Fri Feb 2 23:57:19 2018 using MkDoc