client-node: clear buffers always when freeing mix

Avoid leaking buffers when freeing mix, in case the port was not cleared
properly.

These leaks don't seem to be occurring currently, but better be sure.
This commit is contained in:
Pauli Virtanen 2024-02-03 13:15:31 +02:00 committed by Wim Taymans
parent 0a1afa698e
commit fc6f8e3448

View file

@ -238,18 +238,6 @@ fail:
return NULL;
}
static void free_mix(struct port *p, struct mix *mix)
{
if (mix == NULL)
return;
/* never realloc so it's safe to call from pw_map_foreach */
if (mix->mix_id < pw_map_get_size(&p->mix))
pw_map_insert_at(&p->mix, mix->mix_id, NULL);
free(mix);
}
static void clear_data(struct impl *impl, struct spa_data *d)
{
switch (d->type) {
@ -297,6 +285,27 @@ static int clear_buffers(struct impl *impl, struct mix *mix)
return 0;
}
static void free_mix(struct port *p, struct mix *mix)
{
struct impl *impl = p->impl;
if (mix == NULL)
return;
if (mix->n_buffers) {
/* this shouldn't happen */
spa_log_warn(impl->log, "%p: mix port-id:%u freeing leaked buffers", impl, mix->mix_id - 1u);
}
clear_buffers(impl, mix);
/* never realloc so it's safe to call from pw_map_foreach */
if (mix->mix_id < pw_map_get_size(&p->mix))
pw_map_insert_at(&p->mix, mix->mix_id, NULL);
free(mix);
}
static void mix_clear(struct impl *impl, struct mix *mix)
{
struct port *port = mix->port;