mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
client-node: free old mem after setting new mem
This commit is contained in:
parent
972a790cf2
commit
0efadbb297
1 changed files with 19 additions and 15 deletions
|
|
@ -737,7 +737,7 @@ client_node_port_set_io(void *object,
|
||||||
struct pw_proxy *proxy = object;
|
struct pw_proxy *proxy = object;
|
||||||
struct node_data *data = proxy->user_data;
|
struct node_data *data = proxy->user_data;
|
||||||
struct mix *mix;
|
struct mix *mix;
|
||||||
struct pw_memmap *mm;
|
struct pw_memmap *mm, *old;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
uint32_t tag[5] = { data->remote_id, direction, port_id, mix_id, id };
|
uint32_t tag[5] = { data->remote_id, direction, port_id, mix_id, id };
|
||||||
|
|
@ -745,11 +745,10 @@ client_node_port_set_io(void *object,
|
||||||
mix = ensure_mix(data, direction, port_id, mix_id);
|
mix = ensure_mix(data, direction, port_id, mix_id);
|
||||||
if (mix == NULL) {
|
if (mix == NULL) {
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
goto error_exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mm = pw_mempool_find_tag(data->pool, tag, sizeof(tag))) != NULL)
|
old = pw_mempool_find_tag(data->pool, tag, sizeof(tag));
|
||||||
pw_memmap_free(mm);
|
|
||||||
|
|
||||||
if (memid == SPA_ID_INVALID) {
|
if (memid == SPA_ID_INVALID) {
|
||||||
mm = ptr = NULL;
|
mm = ptr = NULL;
|
||||||
|
|
@ -760,7 +759,7 @@ client_node_port_set_io(void *object,
|
||||||
PW_MEMMAP_FLAG_READWRITE, offset, size, tag);
|
PW_MEMMAP_FLAG_READWRITE, offset, size, tag);
|
||||||
if (mm == NULL) {
|
if (mm == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
goto error_exit;
|
goto exit_free;
|
||||||
}
|
}
|
||||||
ptr = mm->ptr;
|
ptr = mm->ptr;
|
||||||
}
|
}
|
||||||
|
|
@ -771,9 +770,6 @@ client_node_port_set_io(void *object,
|
||||||
if (id == SPA_IO_Buffers) {
|
if (id == SPA_IO_Buffers) {
|
||||||
if (ptr == NULL && mix->mix.io)
|
if (ptr == NULL && mix->mix.io)
|
||||||
deactivate_mix(data, mix);
|
deactivate_mix(data, mix);
|
||||||
mix->mix.io = ptr;
|
|
||||||
if (ptr)
|
|
||||||
activate_mix(data, mix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = spa_node_port_set_io(mix->port->mix,
|
if ((res = spa_node_port_set_io(mix->port->mix,
|
||||||
|
|
@ -781,13 +777,21 @@ client_node_port_set_io(void *object,
|
||||||
if (res == -ENOTSUP)
|
if (res == -ENOTSUP)
|
||||||
res = 0;
|
res = 0;
|
||||||
else
|
else
|
||||||
goto error_exit;
|
goto exit_free;
|
||||||
}
|
}
|
||||||
return res;
|
if (id == SPA_IO_Buffers) {
|
||||||
|
mix->mix.io = ptr;
|
||||||
error_exit:
|
if (ptr)
|
||||||
|
activate_mix(data, mix);
|
||||||
|
}
|
||||||
|
exit_free:
|
||||||
|
if (old != NULL)
|
||||||
|
pw_memmap_free(old);
|
||||||
|
exit:
|
||||||
|
if (res < 0) {
|
||||||
pw_log_error("port %p: set_io: %s", mix, spa_strerror(res));
|
pw_log_error("port %p: set_io: %s", mix, spa_strerror(res));
|
||||||
pw_proxy_errorf(proxy, res, "port_set_io failed: %s", spa_strerror(res));
|
pw_proxy_errorf(proxy, res, "port_set_io failed: %s", spa_strerror(res));
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue