link: improve allocation

Always move the allocated buffers to the output port and reuse them
from there if possible.
This commit is contained in:
Wim Taymans 2018-02-27 12:51:25 +01:00
parent 241a7bc7d9
commit 1ecf982504
3 changed files with 69 additions and 77 deletions

View file

@ -195,16 +195,21 @@ struct allocation {
uint32_t n_buffers; /**< number of port buffers */
};
static inline void drop_allocation(struct allocation *alloc)
static inline void move_allocation(struct allocation *alloc, struct allocation *dest)
{
alloc->buffers = NULL;
alloc->n_buffers = 0;
*dest = *alloc;
alloc->mem = NULL;
}
static inline void free_allocation(struct allocation *alloc)
{
pw_memblock_free(alloc->mem);
free(alloc->buffers);
if (alloc->mem) {
pw_memblock_free(alloc->mem);
free(alloc->buffers);
}
alloc->mem = NULL;
alloc->buffers = NULL;
alloc->n_buffers = 0;
}
struct pw_link {
@ -231,7 +236,6 @@ struct pw_link {
struct spa_hook_list listener_list;
void *allocation_owner;
struct allocation allocation;
struct {