enum pw_memmap_flags {
PW_MEMMAP_FLAG_NONE = 0,
PW_MEMMAP_FLAG_READ = (1 << 0), /**< map in read mode */
PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */
PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice after each other,
* creating a circular ringbuffer */
PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */
PW_MEMMAP_FLAG_LOCKED = (1 << 4), /**< lock the memory into RAM */
PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,
};
struct pw_memchunk;
/** *
* A memory pool is a collection of pw_memblocks */ struct pw_mempool { struct pw_properties *props;
};
/**
* Memory block structure */ struct pw_memblock { struct pw_mempool *pool; /**< owner pool */
uint32_t id; /**< unique id */ int ref; /**< refcount */
uint32_t flags; /**< flags for the memory block on of enum pw_memblock_flags */
uint32_t type; /**< type of the fd, one of enum spa_data_type */ int fd; /**< fd */
uint32_t size; /**< size of memory */ struct pw_memmap *map; /**< optional map when PW_MEMBLOCK_FLAG_MAP was given */
};
/** a mapped region of a pw_memblock */ struct pw_memmap { struct pw_memblock *block; /**< owner memblock */ void *ptr; /**< mapped pointer */
uint32_t flags; /**< flags for the mapping on of enum pw_memmap_flags */
uint32_t offset; /**< offset in memblock */
uint32_t size; /**< size in memblock */
uint32_t tag[5]; /**< user tag */
};
/** Clear a pool */ void pw_mempool_clear(struct pw_mempool *pool);
/** Clear and destroy a pool */ void pw_mempool_destroy(struct pw_mempool *pool);
/** Allocate a memory block from the pool */ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, size_t size);
/** Import a block from another pool */ struct pw_memblock * pw_mempool_import_block(struct pw_mempool *pool, struct pw_memblock *mem);
/** Import an fd into the pool */ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, int fd);
/** Free a memblock regardless of the refcount and destroy all mappings */ void pw_memblock_free(struct pw_memblock *mem);
/** Unref a memblock */ staticinlinevoid pw_memblock_unref(struct pw_memblock *mem)
{ if (--mem->ref == 0)
pw_memblock_free(mem);
}
/** Remove a memblock for given \a id */ int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id);
/** Find memblock for given \a ptr */ struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, constvoid *ptr);
/** Find memblock for given \a id */ struct pw_memblock * pw_mempool_find_id(struct pw_mempool *pool, uint32_t id);
/** Find memblock for given \a fd */ struct pw_memblock * pw_mempool_find_fd(struct pw_mempool *pool, int fd);
/** Map a region of a memory block */ 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 with \a 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]);
/** find a map with the given tag */ struct pw_memmap * pw_mempool_find_tag(struct pw_mempool *pool, uint32_t tag[5], size_t size);
/** Unmap a region */ int pw_memmap_free(struct pw_memmap *map);
/** parameters to map a memory range */ struct pw_map_range {
uint32_t start; /** offset in first page with start of data */
uint32_t offset; /** page aligned offset to map */
uint32_t size; /** size to map */
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.