client-node: always remove the previous io memory

This commit is contained in:
Wim Taymans 2019-08-13 18:43:22 +02:00
parent fa792a91a0
commit f6fca48459
2 changed files with 12 additions and 11 deletions

View file

@ -339,6 +339,9 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
if (impl->this.flags & 1) if (impl->this.flags & 1)
return 0; return 0;
if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
if (data) { if (data) {
mm = pw_mempool_import_map(this->client->pool, mm = pw_mempool_import_map(this->client->pool,
impl->core->pool, data, size, tag); impl->core->pool, data, size, tag);
@ -350,9 +353,6 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
mem_size = size; mem_size = size;
} }
else { else {
if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
memid = SPA_ID_INVALID; memid = SPA_ID_INVALID;
mem_offset = mem_size = 0; mem_offset = mem_size = 0;
} }
@ -652,6 +652,9 @@ static int do_port_set_io(struct impl *impl,
if ((mix = find_mix(port, mix_id)) == NULL || !mix->valid) if ((mix = find_mix(port, mix_id)) == NULL || !mix->valid)
return -EINVAL; return -EINVAL;
if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
if (data) { if (data) {
mm = pw_mempool_import_map(this->client->pool, mm = pw_mempool_import_map(this->client->pool,
impl->core->pool, data, size, tag); impl->core->pool, data, size, tag);
@ -663,9 +666,6 @@ static int do_port_set_io(struct impl *impl,
mem_size = size; mem_size = size;
} }
else { else {
if ((mm = pw_mempool_find_tag(this->client->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
memid = SPA_ID_INVALID; memid = SPA_ID_INVALID;
mem_offset = mem_size = 0; mem_offset = mem_size = 0;
} }

View file

@ -403,9 +403,10 @@ client_node_set_io(void *object,
void *ptr; void *ptr;
uint32_t tag[5] = { data->remote_id, id, }; uint32_t tag[5] = { data->remote_id, id, };
if ((mm = pw_mempool_find_tag(data->remote->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
if (memid == SPA_ID_INVALID) { if (memid == SPA_ID_INVALID) {
if ((mm = pw_mempool_find_tag(data->remote->pool, tag, sizeof(tag))) != NULL)
pw_memmap_free(mm);
mm = ptr = NULL; mm = ptr = NULL;
size = 0; size = 0;
} }
@ -715,10 +716,10 @@ client_node_port_set_io(void *object,
goto error_exit; goto error_exit;
} }
if (memid == SPA_ID_INVALID) { if ((mm = pw_mempool_find_tag(data->remote->pool, tag, sizeof(tag))) != NULL)
if ((mm = pw_mempool_find_tag(data->remote->pool, tag, sizeof(tag))) != NULL) pw_memmap_free(mm);
pw_memmap_free(mm);
if (memid == SPA_ID_INVALID) {
mm = ptr = NULL; mm = ptr = NULL;
size = 0; size = 0;
} }