impl-port: only add and remove the mix info once

Or we might crash.
This commit is contained in:
Wim Taymans 2023-06-21 10:24:57 +02:00
parent 265e6ca352
commit 1e4adff3fa
2 changed files with 10 additions and 3 deletions

View file

@ -132,7 +132,10 @@ do_add_mix(struct spa_loop *loop,
struct pw_impl_port *this = mix->p; struct pw_impl_port *this = mix->p;
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
pw_log_trace("%p: add mix %p", this, mix); pw_log_trace("%p: add mix %p", this, mix);
spa_list_append(&impl->mix_list, &mix->rt_link); if (!mix->active) {
spa_list_append(&impl->mix_list, &mix->rt_link);
mix->active = true;
}
return 0; return 0;
} }
@ -143,7 +146,10 @@ do_remove_mix(struct spa_loop *loop,
struct pw_impl_port_mix *mix = user_data; struct pw_impl_port_mix *mix = user_data;
struct pw_impl_port *this = mix->p; struct pw_impl_port *this = mix->p;
pw_log_trace("%p: remove mix %p", this, mix); pw_log_trace("%p: remove mix %p", this, mix);
spa_list_remove(&mix->rt_link); if (mix->active) {
spa_list_remove(&mix->rt_link);
mix->active = false;
}
return 0; return 0;
} }
@ -157,7 +163,7 @@ static int port_set_io(void *object,
mix = find_mix(this, direction, port_id); mix = find_mix(this, direction, port_id);
if (mix == NULL) if (mix == NULL)
return 0; return -ENOENT;
if (id == SPA_IO_Buffers) { if (id == SPA_IO_Buffers) {
if (data == NULL || size == 0) { if (data == NULL || size == 0) {

View file

@ -823,6 +823,7 @@ struct pw_impl_port_mix {
uint32_t id; uint32_t id;
uint32_t peer_id; uint32_t peer_id;
unsigned int have_buffers:1; unsigned int have_buffers:1;
unsigned int active:1;
}; };
struct pw_impl_port_implementation { struct pw_impl_port_implementation {