jack: free old mem after we configure new mem

This commit is contained in:
Wim Taymans 2020-06-05 13:02:56 +02:00
parent bf4ccc00bf
commit 6ee9853133

View file

@ -1754,7 +1754,7 @@ static int client_node_port_set_io(void *object,
{ {
struct client *c = (struct client *) object; struct client *c = (struct client *) object;
struct port *p = GET_PORT(c, direction, port_id); struct port *p = GET_PORT(c, direction, port_id);
struct pw_memmap *mm; struct pw_memmap *mm, *old;
struct mix *mix; struct mix *mix;
uint32_t tag[5] = { c->node_id, direction, port_id, mix_id, id }; uint32_t tag[5] = { c->node_id, direction, port_id, mix_id, id };
void *ptr; void *ptr;
@ -1765,8 +1765,7 @@ static int client_node_port_set_io(void *object,
goto exit; goto exit;
} }
if ((mm = pw_mempool_find_tag(c->pool, tag, sizeof(tag))) != NULL) old = pw_mempool_find_tag(c->pool, tag, sizeof(tag));
pw_memmap_free(mm);
if (mem_id == SPA_ID_INVALID) { if (mem_id == SPA_ID_INVALID) {
mm = ptr = NULL; mm = ptr = NULL;
@ -1778,7 +1777,7 @@ static int client_node_port_set_io(void *object,
if (mm == NULL) { if (mm == NULL) {
pw_log_warn(NAME" %p: can't map memory id %u", c, mem_id); pw_log_warn(NAME" %p: can't map memory id %u", c, mem_id);
res = -EINVAL; res = -EINVAL;
goto exit; goto exit_free;
} }
ptr = mm->ptr; ptr = mm->ptr;
} }
@ -1793,8 +1792,10 @@ static int client_node_port_set_io(void *object,
default: default:
break; break;
} }
exit_free:
exit: if (old != NULL)
pw_memmap_free(old);
exit:
if (res < 0) if (res < 0)
pw_proxy_error((struct pw_proxy*)c->node, res, spa_strerror(res)); pw_proxy_error((struct pw_proxy*)c->node, res, spa_strerror(res));
return res; return res;