From 49afacd66fef5eb7824745d0d8a5dafeda62feec Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 22 Nov 2018 10:54:57 +0100 Subject: [PATCH] v4l2: fix crash when unplugging Only remove the v4l2 fd once on disconnect Make sure we don't use the clock anymore when a link is destroyed. --- spa/plugins/v4l2/v4l2-utils.c | 6 ++++-- src/pipewire/link.c | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 56e2c9bb9..34bb2bcda 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -1194,7 +1194,8 @@ static void v4l2_on_fd_events(struct spa_source *source) if (source->rmask & SPA_IO_ERR) { struct port *port = &this->out_ports[0]; spa_log_error(this->log, "v4l2 %p: error %d", this, source->rmask); - spa_loop_remove_source(port->data_loop, &port->source); + if (port->source.loop) + spa_loop_remove_source(port->data_loop, &port->source); return; } @@ -1470,7 +1471,8 @@ static int do_remove_source(struct spa_loop *loop, void *user_data) { struct port *port = user_data; - spa_loop_remove_source(port->data_loop, &port->source); + if (port->source.loop) + spa_loop_remove_source(port->data_loop, &port->source); return 0; } diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 0fc89f90d..8a4dbeaf8 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1288,6 +1288,9 @@ void pw_link_destroy(struct pw_link *link) if (link->registered) spa_list_remove(&link->link); + if (link->output->node->clock == link->input->node->clock) + link->input->node->clock = NULL; + input_remove(link, link->input); output_remove(link, link->output);