PipeWire  0.3.61
Memory Blocks

Memory allocation and pools. More...

Files

file  mem.h
 pipewire/mem.h
 

Data Structures

struct  pw_mempool
 A memory pool is a collection of pw_memblocks. More...
 
struct  pw_memblock
 Memory block structure. More...
 
struct  pw_memmap
 a mapped region of a pw_memblock More...
 
struct  pw_mempool_events
 
struct  pw_map_range
 parameters to map a memory range More...
 
struct  pw_memchunk
 

Macros

#define PW_VERSION_MEMPOOL_EVENTS   0
 
#define PW_MAP_RANGE_INIT   (struct pw_map_range){ 0, }
 

Enumerations

enum  pw_memblock_flags {
  PW_MEMBLOCK_FLAG_NONE = 0 , PW_MEMBLOCK_FLAG_READABLE = (1 << 0) , PW_MEMBLOCK_FLAG_WRITABLE = (1 << 1) , PW_MEMBLOCK_FLAG_SEAL = (1 << 2) ,
  PW_MEMBLOCK_FLAG_MAP = (1 << 3) , PW_MEMBLOCK_FLAG_DONT_CLOSE = (1 << 4) , PW_MEMBLOCK_FLAG_DONT_NOTIFY = (1 << 5) , PW_MEMBLOCK_FLAG_READWRITE = PW_MEMBLOCK_FLAG_READABLE | PW_MEMBLOCK_FLAG_WRITABLE
}
 Flags passed to pw_mempool_alloc() More...
 
enum  pw_memmap_flags {
  PW_MEMMAP_FLAG_NONE = 0 , PW_MEMMAP_FLAG_READ = (1 << 0) , PW_MEMMAP_FLAG_WRITE = (1 << 1) , PW_MEMMAP_FLAG_TWICE = (1 << 2) ,
  PW_MEMMAP_FLAG_PRIVATE = (1 << 3) , PW_MEMMAP_FLAG_LOCKED = (1 << 4) , PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE
}
 

Functions

struct pw_mempoolpw_mempool_new (struct pw_properties *props)
 Create a new memory pool. More...
 
void pw_mempool_add_listener (struct pw_mempool *pool, struct spa_hook *listener, const struct pw_mempool_events *events, void *data)
 Listen for events. More...
 
void pw_mempool_clear (struct pw_mempool *pool)
 Clear a pool. More...
 
void pw_mempool_destroy (struct pw_mempool *pool)
 Clear and destroy a pool. More...
 
struct pw_memblockpw_mempool_alloc (struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, size_t size)
 Allocate a memory block from the pool. More...
 
struct pw_memblockpw_mempool_import_block (struct pw_mempool *pool, struct pw_memblock *mem)
 Import a block from another pool. More...
 
struct pw_memblockpw_mempool_import (struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, int fd)
 Import an fd into the pool. More...
 
void pw_memblock_free (struct pw_memblock *mem)
 Free a memblock regardless of the refcount and destroy all mappings. More...
 
static void pw_memblock_unref (struct pw_memblock *mem)
 Unref a memblock. More...
 
int pw_mempool_remove_id (struct pw_mempool *pool, uint32_t id)
 Remove a memblock for given id. More...
 
struct pw_memblockpw_mempool_find_ptr (struct pw_mempool *pool, const void *ptr)
 Find memblock for given ptr. More...
 
struct pw_memblockpw_mempool_find_id (struct pw_mempool *pool, uint32_t id)
 Find memblock for given id. More...
 
struct pw_memblockpw_mempool_find_fd (struct pw_mempool *pool, int fd)
 Find memblock for given fd. More...
 
struct pw_memmappw_memblock_map (struct pw_memblock *block, enum pw_memmap_flags flags, uint32_t offset, uint32_t size, uint32_t tag[5])
 Map a region of a memory block. More...
 
struct pw_memmappw_mempool_map_id (struct pw_mempool *pool, uint32_t id, enum pw_memmap_flags flags, uint32_t offset, uint32_t size, uint32_t tag[5])
 Map a region of a memory block with id. More...
 
struct pw_memmappw_mempool_import_map (struct pw_mempool *pool, struct pw_mempool *other, void *data, uint32_t size, uint32_t tag[5])
 
struct pw_memmappw_mempool_find_tag (struct pw_mempool *pool, uint32_t tag[5], size_t size)
 find a map with the given tag More...
 
int pw_memmap_free (struct pw_memmap *map)
 Unmap a region. More...
 
static void pw_map_range_init (struct pw_map_range *range, uint32_t offset, uint32_t size, uint32_t page_size)
 Calculate parameters to mmap() memory into range so that size bytes at offset can be mapped with mmap(). More...
 

Detailed Description

Memory allocation and pools.

Macro Definition Documentation

◆ PW_VERSION_MEMPOOL_EVENTS

#define PW_VERSION_MEMPOOL_EVENTS   0

◆ PW_MAP_RANGE_INIT

#define PW_MAP_RANGE_INIT   (struct pw_map_range){ 0, }

Enumeration Type Documentation

◆ pw_memblock_flags

Flags passed to pw_mempool_alloc()

Enumerator
PW_MEMBLOCK_FLAG_NONE 
PW_MEMBLOCK_FLAG_READABLE 

memory is readable

PW_MEMBLOCK_FLAG_WRITABLE 

memory is writable

PW_MEMBLOCK_FLAG_SEAL 

seal the fd

PW_MEMBLOCK_FLAG_MAP 

mmap the fd

PW_MEMBLOCK_FLAG_DONT_CLOSE 

don't close fd

PW_MEMBLOCK_FLAG_DONT_NOTIFY 

don't notify events

PW_MEMBLOCK_FLAG_READWRITE 

◆ pw_memmap_flags

Enumerator
PW_MEMMAP_FLAG_NONE 
PW_MEMMAP_FLAG_READ 

map in read mode

PW_MEMMAP_FLAG_WRITE 

map in write mode

PW_MEMMAP_FLAG_TWICE 

map the same area twice after each other, creating a circular ringbuffer

PW_MEMMAP_FLAG_PRIVATE 

writes will be private

PW_MEMMAP_FLAG_LOCKED 

lock the memory into RAM

PW_MEMMAP_FLAG_READWRITE 

Function Documentation

◆ pw_mempool_new()

struct pw_mempool* pw_mempool_new ( struct pw_properties props)

Create a new memory pool.

◆ pw_mempool_add_listener()

void pw_mempool_add_listener ( struct pw_mempool pool,
struct spa_hook listener,
const struct pw_mempool_events events,
void *  data 
)

Listen for events.

◆ pw_mempool_clear()

void pw_mempool_clear ( struct pw_mempool pool)

Clear a pool.

◆ pw_mempool_destroy()

void pw_mempool_destroy ( struct pw_mempool pool)

Clear and destroy a pool.

◆ pw_mempool_alloc()

struct pw_memblock* pw_mempool_alloc ( struct pw_mempool pool,
enum pw_memblock_flags  flags,
uint32_t  type,
size_t  size 
)

Allocate a memory block from the pool.

Allocate a memory block from the pool.

Parameters
poolthe pool to use
flagsmemblock flags
typethe requested memory type one of enum spa_data_type
sizesize to allocate
Returns
a memblock structure or NULL with errno on error

◆ pw_mempool_import_block()

struct pw_memblock* pw_mempool_import_block ( struct pw_mempool pool,
struct pw_memblock mem 
)

Import a block from another pool.

◆ pw_mempool_import()

struct pw_memblock* pw_mempool_import ( struct pw_mempool pool,
enum pw_memblock_flags  flags,
uint32_t  type,
int  fd 
)

Import an fd into the pool.

◆ pw_memblock_free()

void pw_memblock_free ( struct pw_memblock block)

Free a memblock regardless of the refcount and destroy all mappings.

Free a memblock regardless of the refcount and destroy all mappings.

Parameters
blocka memblock

◆ pw_memblock_unref()

static void pw_memblock_unref ( struct pw_memblock mem)
inlinestatic

Unref a memblock.

◆ pw_mempool_remove_id()

int pw_mempool_remove_id ( struct pw_mempool pool,
uint32_t  id 
)

Remove a memblock for given id.

◆ pw_mempool_find_ptr()

struct pw_memblock* pw_mempool_find_ptr ( struct pw_mempool pool,
const void *  ptr 
)

Find memblock for given ptr.

◆ pw_mempool_find_id()

struct pw_memblock* pw_mempool_find_id ( struct pw_mempool pool,
uint32_t  id 
)

Find memblock for given id.

◆ pw_mempool_find_fd()

struct pw_memblock* pw_mempool_find_fd ( struct pw_mempool pool,
int  fd 
)

Find memblock for given fd.

◆ pw_memblock_map()

struct pw_memmap* pw_memblock_map ( struct pw_memblock block,
enum pw_memmap_flags  flags,
uint32_t  offset,
uint32_t  size,
uint32_t  tag[5] 
)

Map a region of a memory block.

◆ pw_mempool_map_id()

struct pw_memmap* pw_mempool_map_id ( struct pw_mempool pool,
uint32_t  id,
enum pw_memmap_flags  flags,
uint32_t  offset,
uint32_t  size,
uint32_t  tag[5] 
)

Map a region of a memory block with id.

◆ pw_mempool_import_map()

struct pw_memmap* pw_mempool_import_map ( struct pw_mempool pool,
struct pw_mempool other,
void *  data,
uint32_t  size,
uint32_t  tag[5] 
)

◆ pw_mempool_find_tag()

struct pw_memmap* pw_mempool_find_tag ( struct pw_mempool pool,
uint32_t  tag[5],
size_t  size 
)

find a map with the given tag

◆ pw_memmap_free()

int pw_memmap_free ( struct pw_memmap map)

Unmap a region.

◆ pw_map_range_init()

static void pw_map_range_init ( struct pw_map_range range,
uint32_t  offset,
uint32_t  size,
uint32_t  page_size 
)
inlinestatic

Calculate parameters to mmap() memory into range so that size bytes at offset can be mapped with mmap().