25 #ifndef PIPEWIRE_MEM_H 26 #define PIPEWIRE_MEM_H 100 #define PW_VERSION_MEMPOOL_EVENTS 0 191 #define PW_MAP_RANGE_INIT (struct pw_map_range){ 0, } 196 uint32_t offset, uint32_t size,
200 range->start = offset - range->
offset;
struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *ptr)
Find memblock for given ptr.
Definition: mem.c:735
writes will be private
Definition: mem.h:66
parameters to map a memory range
Definition: mem.h:191
Definition: properties.h:53
void pw_mempool_destroy(struct pw_mempool *pool)
Clear and destroy a pool.
Definition: mem.c:172
struct pw_memmap * map
optional map when PW_MEMBLOCK_FLAG_MAP was given
Definition: mem.h:91
map in read mode
Definition: mem.h:62
uint32_t offset
offset in first page with start of data
Definition: mem.h:193
memory is writable
Definition: mem.h:51
int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id)
Remove a memblock for given id.
Definition: mem.c:672
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
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
Definition: mem.c:780
struct pw_memblock * block
owner memblock
Definition: mem.h:96
struct pw_memblock * pw_mempool_find_fd(struct pw_mempool *pool, int fd)
Find memblock for given fd.
Definition: mem.c:768
void * ptr
mapped pointer
Definition: mem.h:97
uint32_t type
type of the fd, one of enum spa_data_type
Definition: mem.h:88
don't notify events
Definition: mem.h:55
uint32_t version
Definition: mem.h:107
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.
Definition: mem.c:571
uint32_t flags
flags for the memory block on of enum pw_memblock_flags
Definition: mem.h:87
int pw_memmap_free(struct pw_memmap *map)
Unmap a region.
Definition: mem.c:420
pw_memmap_flags
Definition: mem.h:60
seal the fd
Definition: mem.h:52
uint32_t size
size in memblock
Definition: mem.h:100
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.
Definition: mem.c:358
int fd
fd
Definition: mem.h:89
static void pw_memblock_unref(struct pw_memblock *mem)
Unref a memblock.
Definition: mem.h:151
uint32_t offset
offset in memblock
Definition: mem.h:99
void pw_mempool_clear(struct pw_mempool *pool)
Clear a pool.
Definition: mem.c:159
struct pw_mempool * pool
owner pool
Definition: mem.h:84
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:296
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...
Definition: mem.h:202
void(* destroy)(void *data)
the pool is destroyed
Definition: mem.h:110
void(* added)(void *data, struct pw_memblock *block)
a new memory block is added to the pool
Definition: mem.h:113
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.
Definition: mem.c:468
a mapped region of a pw_memblock
Definition: mem.h:95
uint32_t flags
flags for the mapping on of enum pw_memmap_flags
Definition: mem.h:98
uint32_t id
unique id
Definition: mem.h:85
int ref
refcount
Definition: mem.h:86
Memory block structure.
Definition: mem.h:83
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.
Definition: mem.c:405
uint32_t tag[5]
user tag
Definition: mem.h:101
memory is readable
Definition: mem.h:50
pw_memblock_flags
Flags passed to pw_mempool_alloc()
Definition: mem.h:48
mmap the fd
Definition: mem.h:53
void pw_mempool_add_listener(struct pw_mempool *pool, struct spa_hook *listener, const struct pw_mempool_events *events, void *data)
Listen for events.
Definition: mem.c:190
uint32_t size
size of memory
Definition: mem.h:90
don't close fd
Definition: mem.h:54
map in write mode
Definition: mem.h:63
void(* removed)(void *data, struct pw_memblock *block)
a memory block is removed from the pool
Definition: mem.h:116
struct pw_memmap * pw_mempool_import_map(struct pw_mempool *pool, struct pw_mempool *other, void *data, uint32_t size, uint32_t tag[5])
Definition: mem.c:619
struct pw_memblock * pw_mempool_import_block(struct pw_mempool *pool, struct pw_memblock *mem)
Import a block from another pool.
Definition: mem.c:608
struct pw_mempool * pw_mempool_new(struct pw_properties *props)
Create a new memory pool.
Definition: mem.c:135
A memory pool is a collection of pw_memblocks.
Definition: mem.h:77
#define SPA_ROUND_DOWN_N(num, align)
Definition: defs.h:294
uint32_t size
page aligned offset to map
Definition: mem.h:194
void pw_memblock_free(struct pw_memblock *mem)
Free a memblock regardless of the refcount and destroy all mappings.
Definition: mem.c:695
lock the memory into RAM
Definition: mem.h:67
map the same area twice after each other, creating a circular ringbuffer
Definition: mem.h:64
struct pw_memblock * pw_mempool_find_id(struct pw_mempool *pool, uint32_t id)
Find memblock for given id.
Definition: mem.c:754