mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
mem: improve memory handling
Add a memory pool to manage blocks of memory. Make it possible to allocate and import blocks. Add add_mem and remove_mem to the core events to signal a client of a block of memory. Remove the client-node add_mem. Make a global pool for memory and a per client pool where we import and share the memory we need with the client. Use the new memory pool to track and map memory in clients.
This commit is contained in:
parent
a8bc8e1b1e
commit
2caf81c97c
16 changed files with 903 additions and 689 deletions
|
|
@ -99,6 +99,7 @@ struct pw_client {
|
|||
|
||||
struct pw_client_info info; /**< client info */
|
||||
|
||||
struct pw_mempool *pool; /**< client mempool */
|
||||
struct pw_resource *core_resource; /**< core resource object */
|
||||
struct pw_resource *client_resource; /**< client resource object */
|
||||
|
||||
|
|
@ -159,11 +160,13 @@ struct pw_global {
|
|||
#define pw_core_emit_global_removed(c,g) pw_core_emit(c, global_removed, 0, g)
|
||||
|
||||
#define pw_core_resource(r,m,v,...) pw_resource_call(r, struct pw_core_proxy_events, m, v, ##__VA_ARGS__)
|
||||
#define pw_core_resource_info(r,...) pw_core_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_core_resource_done(r,...) pw_core_resource(r,done,0,__VA_ARGS__)
|
||||
#define pw_core_resource_ping(r,...) pw_core_resource(r,ping,0,__VA_ARGS__)
|
||||
#define pw_core_resource_error(r,...) pw_core_resource(r,error,0,__VA_ARGS__)
|
||||
#define pw_core_resource_remove_id(r,...) pw_core_resource(r,remove_id,0,__VA_ARGS__)
|
||||
#define pw_core_resource_info(r,...) pw_core_resource(r,info,0,__VA_ARGS__)
|
||||
#define pw_core_resource_done(r,...) pw_core_resource(r,done,0,__VA_ARGS__)
|
||||
#define pw_core_resource_ping(r,...) pw_core_resource(r,ping,0,__VA_ARGS__)
|
||||
#define pw_core_resource_error(r,...) pw_core_resource(r,error,0,__VA_ARGS__)
|
||||
#define pw_core_resource_remove_id(r,...) pw_core_resource(r,remove_id,0,__VA_ARGS__)
|
||||
#define pw_core_resource_add_mem(r,...) pw_core_resource(r,add_mem,0,__VA_ARGS__)
|
||||
#define pw_core_resource_remove_mem(r,...) pw_core_resource(r,remove_mem,0,__VA_ARGS__)
|
||||
|
||||
static inline void
|
||||
pw_core_resource_errorv(struct pw_resource *resource, uint32_t id, int seq,
|
||||
|
|
@ -198,6 +201,8 @@ struct pw_core {
|
|||
|
||||
struct pw_properties *properties; /**< properties of the core */
|
||||
|
||||
struct pw_mempool *pool; /**< global memory pool */
|
||||
|
||||
struct pw_map globals; /**< map of globals */
|
||||
|
||||
struct spa_list protocol_list; /**< list of protocols */
|
||||
|
|
@ -273,7 +278,7 @@ static inline void move_allocation(struct allocation *alloc, struct allocation *
|
|||
static inline void free_allocation(struct allocation *alloc)
|
||||
{
|
||||
if (alloc->mem) {
|
||||
pw_memblock_free(alloc->mem);
|
||||
pw_memblock_unref(alloc->mem);
|
||||
free(alloc->buffers);
|
||||
}
|
||||
alloc->mem = NULL;
|
||||
|
|
@ -669,6 +674,7 @@ struct pw_remote {
|
|||
struct spa_list link; /**< link in core remote_list */
|
||||
struct pw_properties *properties; /**< extra properties */
|
||||
|
||||
struct pw_mempool *pool; /**< memory pool */
|
||||
struct pw_core_proxy *core_proxy; /**< proxy for the core object */
|
||||
struct pw_map objects; /**< map of client side proxy objects
|
||||
* indexed with the client id */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue