mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
pulsecore: Reference count mempools
In future commits, server-wide SHMs will be replaced with per-client ones that will be dynamically created and freed according to clients connections open and close. Meanwhile, current PA design does not guarantee that the per-client mempool blocks are referenced only by client-specific objects. Thus reference count the pools and let each memblock inside the pool itself, or just attached to it, increment the pool's refcount upon allocation. This way, per-client mempools will only be freed when no further component in the system holds any references to its blocks. DiscussionLink: https://goo.gl/qesVMV Suggested-by: Tanu Kaskinen <tanuk@iki.fi> Suggested-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
This commit is contained in:
parent
1f5e72264e
commit
9bda6e344a
17 changed files with 84 additions and 20 deletions
|
|
@ -530,6 +530,7 @@ int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk) {
|
|||
}
|
||||
|
||||
int pa_memblockq_peek_fixed_size(pa_memblockq *bq, size_t block_size, pa_memchunk *chunk) {
|
||||
pa_mempool *pool;
|
||||
pa_memchunk tchunk, rchunk;
|
||||
int64_t ri;
|
||||
struct list_item *item;
|
||||
|
|
@ -548,9 +549,11 @@ int pa_memblockq_peek_fixed_size(pa_memblockq *bq, size_t block_size, pa_memchun
|
|||
return 0;
|
||||
}
|
||||
|
||||
rchunk.memblock = pa_memblock_new(pa_memblock_get_pool(tchunk.memblock), block_size);
|
||||
pool = pa_memblock_get_pool(tchunk.memblock);
|
||||
rchunk.memblock = pa_memblock_new(pool, block_size);
|
||||
rchunk.index = 0;
|
||||
rchunk.length = tchunk.length;
|
||||
pa_mempool_unref(pool), pool = NULL;
|
||||
|
||||
pa_memchunk_memcpy(&rchunk, &tchunk);
|
||||
pa_memblock_unref(tchunk.memblock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue