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,7 +515,8 @@ 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);
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; 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", 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);
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; return &b->this;
} }
@ -687,7 +689,8 @@ 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);
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) spa_list_consume(mm, &b->memmaps, link)
pw_memmap_free(&mm->this); pw_memmap_free(&mm->this);

View file

@ -33,23 +33,24 @@ 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,
}; };
enum pw_memmap_flags { enum pw_memmap_flags {
PW_MEMMAP_FLAG_NONE = 0, PW_MEMMAP_FLAG_NONE = 0,
PW_MEMMAP_FLAG_READ = (1 << 0), /**< map in read mode */ PW_MEMMAP_FLAG_READ = (1 << 0), /**< map in read mode */
PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */ PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */
PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice afer eachother, PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice afer eachother,
* creating a circular ringbuffer */ * creating a circular ringbuffer */
PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */ PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */
PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE, PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,
}; };