From 803c2860ed628a24f3afd35f0c5be03cf9d3cab3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 2 Jun 2020 14:05:57 +0200 Subject: [PATCH] mem: add flag to suppress notify --- src/pipewire/mem.c | 9 ++++++--- src/pipewire/mem.h | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index dedf90252..79d946723 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -515,7 +515,8 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_ spa_list_append(&impl->blocks, &b->link); pw_log_debug(NAME" %p: block:%p id:%d type:%u size:%zd", pool, &b->this, b->this.id, type, size); - pw_mempool_emit_added(impl, &b->this); + if (!SPA_FLAG_IS_SET(flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY)) + pw_mempool_emit_added(impl, &b->this); return &b->this; @@ -573,7 +574,8 @@ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool, pw_log_debug(NAME" %p: block:%p id:%u flags:%08x type:%u fd:%d", pool, b, b->this.id, flags, type, fd); - pw_mempool_emit_added(impl, &b->this); + if (!SPA_FLAG_IS_SET(flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY)) + pw_mempool_emit_added(impl, &b->this); return &b->this; } @@ -687,7 +689,8 @@ void pw_memblock_free(struct pw_memblock *block) pw_map_remove(&impl->map, block->id); spa_list_remove(&b->link); - pw_mempool_emit_removed(impl, block); + if (!SPA_FLAG_IS_SET(block->flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY)) + pw_mempool_emit_removed(impl, block); spa_list_consume(mm, &b->memmaps, link) pw_memmap_free(&mm->this); diff --git a/src/pipewire/mem.h b/src/pipewire/mem.h index 6b7a1db82..8d809647a 100644 --- a/src/pipewire/mem.h +++ b/src/pipewire/mem.h @@ -33,23 +33,24 @@ extern "C" { /** Flags passed to \ref pw_mempool_alloc() \memberof pw_memblock */ 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_NONE = 0, + PW_MEMBLOCK_FLAG_READABLE = (1 << 0), /**< memory is readable */ + PW_MEMBLOCK_FLAG_WRITABLE = (1 << 1), /**< memory is writable */ + PW_MEMBLOCK_FLAG_SEAL = (1 << 2), /**< seal the fd */ + PW_MEMBLOCK_FLAG_MAP = (1 << 3), /**< mmap the fd */ + PW_MEMBLOCK_FLAG_DONT_CLOSE = (1 << 4), /**< don't close fd */ + PW_MEMBLOCK_FLAG_DONT_NOTIFY = (1 << 5), /**< don't notify events */ PW_MEMBLOCK_FLAG_READWRITE = PW_MEMBLOCK_FLAG_READABLE | PW_MEMBLOCK_FLAG_WRITABLE, }; 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 afer eachother, - * creating a circular ringbuffer */ - PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */ + 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 afer eachother, + * creating a circular ringbuffer */ + PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */ PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE, };