mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
mem: implement remove_id
Rename (the non-exported symbol) _unref_id -> _remove_id and make it remove the id from the map of known ids. This way, the server can send the remove_mem and reuse the id for new memory before all references are gone. Fixes "invalid mem id X, expected Y" errors.
This commit is contained in:
parent
d68e7ed58a
commit
8ab67c5fa0
3 changed files with 9 additions and 6 deletions
|
|
@ -115,7 +115,7 @@ static void core_event_remove_mem(void *data, uint32_t id)
|
||||||
{
|
{
|
||||||
struct pw_core *this = data;
|
struct pw_core *this = data;
|
||||||
pw_log_debug(NAME" %p: remove mem %u", this, id);
|
pw_log_debug(NAME" %p: remove mem %u", this, id);
|
||||||
pw_mempool_unref_id(this->pool, id);
|
pw_mempool_remove_id(this->pool, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_core_events core_events = {
|
static const struct pw_core_events core_events = {
|
||||||
|
|
|
||||||
|
|
@ -623,8 +623,7 @@ struct pw_memmap * pw_mempool_import_map(struct pw_mempool *pool,
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id)
|
||||||
int pw_mempool_unref_id(struct pw_mempool *pool, uint32_t id)
|
|
||||||
{
|
{
|
||||||
struct mempool *impl = SPA_CONTAINER_OF(pool, struct mempool, this);
|
struct mempool *impl = SPA_CONTAINER_OF(pool, struct mempool, this);
|
||||||
struct memblock *b;
|
struct memblock *b;
|
||||||
|
|
@ -636,7 +635,10 @@ int pw_mempool_unref_id(struct pw_mempool *pool, uint32_t id)
|
||||||
pw_log_debug(NAME" %p: block:%p id:%d fd:%d ref:%d",
|
pw_log_debug(NAME" %p: block:%p id:%d fd:%d ref:%d",
|
||||||
pool, b, id, b->this.fd, b->this.ref);
|
pool, b, id, b->this.fd, b->this.ref);
|
||||||
|
|
||||||
|
b->this.id = SPA_ID_INVALID;
|
||||||
|
pw_map_remove(&impl->map, id);
|
||||||
pw_memblock_unref(&b->this);
|
pw_memblock_unref(&b->this);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -661,7 +663,8 @@ void pw_memblock_free(struct pw_memblock *block)
|
||||||
if (block->map)
|
if (block->map)
|
||||||
block->ref++;
|
block->ref++;
|
||||||
|
|
||||||
pw_map_remove(&impl->map, block->id);
|
if (block->id != SPA_ID_INVALID)
|
||||||
|
pw_map_remove(&impl->map, block->id);
|
||||||
spa_list_remove(&b->link);
|
spa_list_remove(&b->link);
|
||||||
|
|
||||||
pw_mempool_emit_removed(impl, block);
|
pw_mempool_emit_removed(impl, block);
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,8 @@ static inline void pw_memblock_unref(struct pw_memblock *mem)
|
||||||
pw_memblock_free(mem);
|
pw_memblock_free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unref a memblock for given \a id */
|
/** Remove a memblock for given \a id */
|
||||||
int pw_mempool_unref_id(struct pw_mempool *pool, uint32_t id);
|
int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id);
|
||||||
|
|
||||||
/** Find memblock for given \a ptr */
|
/** Find memblock for given \a ptr */
|
||||||
struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *ptr);
|
struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *ptr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue