mem: add flag to suppress notify

This commit is contained in:
Wim Taymans 2020-06-02 14:05:57 +02:00
parent 6ecbe00774
commit 803c2860ed
2 changed files with 19 additions and 15 deletions

View file

@ -515,6 +515,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
spa_list_append(&impl->blocks, &b->link); 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_log_debug(NAME" %p: block:%p id:%d type:%u size:%zd", pool, &b->this, b->this.id, type, size);
if (!SPA_FLAG_IS_SET(flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY))
pw_mempool_emit_added(impl, &b->this); pw_mempool_emit_added(impl, &b->this);
return &b->this; return &b->this;
@ -573,6 +574,7 @@ 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", pw_log_debug(NAME" %p: block:%p id:%u flags:%08x type:%u fd:%d",
pool, b, b->this.id, flags, type, fd); pool, b, b->this.id, flags, type, fd);
if (!SPA_FLAG_IS_SET(flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY))
pw_mempool_emit_added(impl, &b->this); pw_mempool_emit_added(impl, &b->this);
return &b->this; return &b->this;
@ -687,6 +689,7 @@ void pw_memblock_free(struct pw_memblock *block)
pw_map_remove(&impl->map, block->id); pw_map_remove(&impl->map, block->id);
spa_list_remove(&b->link); spa_list_remove(&b->link);
if (!SPA_FLAG_IS_SET(block->flags, PW_MEMBLOCK_FLAG_DONT_NOTIFY))
pw_mempool_emit_removed(impl, block); pw_mempool_emit_removed(impl, block);
spa_list_consume(mm, &b->memmaps, link) spa_list_consume(mm, &b->memmaps, link)

View file

@ -34,11 +34,12 @@ extern "C" {
/** Flags passed to \ref pw_mempool_alloc() \memberof pw_memblock */ /** Flags passed to \ref pw_mempool_alloc() \memberof pw_memblock */
enum pw_memblock_flags { enum pw_memblock_flags {
PW_MEMBLOCK_FLAG_NONE = 0, PW_MEMBLOCK_FLAG_NONE = 0,
PW_MEMBLOCK_FLAG_READABLE = (1 << 0), PW_MEMBLOCK_FLAG_READABLE = (1 << 0), /**< memory is readable */
PW_MEMBLOCK_FLAG_WRITABLE = (1 << 1), PW_MEMBLOCK_FLAG_WRITABLE = (1 << 1), /**< memory is writable */
PW_MEMBLOCK_FLAG_SEAL = (1 << 2), PW_MEMBLOCK_FLAG_SEAL = (1 << 2), /**< seal the fd */
PW_MEMBLOCK_FLAG_MAP = (1 << 3), PW_MEMBLOCK_FLAG_MAP = (1 << 3), /**< mmap the fd */
PW_MEMBLOCK_FLAG_DONT_CLOSE = (1 << 4), 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, PW_MEMBLOCK_FLAG_READWRITE = PW_MEMBLOCK_FLAG_READABLE | PW_MEMBLOCK_FLAG_WRITABLE,
}; };