From 53796a45cd961537f92e147ec6ad5aed124af7b5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 8 Nov 2022 15:47:55 +0100 Subject: [PATCH] v4l2: mark the fd as closed instead of -1 Or else we won't be able to close the fd later. --- pipewire-v4l2/src/pipewire-v4l2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pipewire-v4l2/src/pipewire-v4l2.c b/pipewire-v4l2/src/pipewire-v4l2.c index b4b5125b8..927a37f7f 100644 --- a/pipewire-v4l2/src/pipewire-v4l2.c +++ b/pipewire-v4l2/src/pipewire-v4l2.c @@ -138,6 +138,7 @@ struct file { uint32_t last_fourcc; unsigned int running:1; + unsigned int closed:1; int fd; }; @@ -400,7 +401,7 @@ static struct file *find_file_by_dev(uint32_t dev) pthread_mutex_lock(&globals.lock); pw_array_for_each(tmp, &globals.fd_maps) { if (tmp->file->dev_id == dev) { - if (tmp->file->fd == -1) + if (tmp->file->closed) tmp->file->fd = tmp->fd; ATOMIC_INC(tmp->file->ref); map = tmp; @@ -901,9 +902,8 @@ static int v4l2_close(int fd) if (fd != file->fd) spa_system_close(file->l->system, fd); - else - file->fd = -1; + file->closed = true; unref_file(file); return 0;