mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
v4l2: mark the fd as closed instead of -1
Or else we won't be able to close the fd later.
This commit is contained in:
parent
67dcb72295
commit
53796a45cd
1 changed files with 3 additions and 3 deletions
|
|
@ -138,6 +138,7 @@ struct file {
|
||||||
uint32_t last_fourcc;
|
uint32_t last_fourcc;
|
||||||
|
|
||||||
unsigned int running:1;
|
unsigned int running:1;
|
||||||
|
unsigned int closed:1;
|
||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -400,7 +401,7 @@ static struct file *find_file_by_dev(uint32_t dev)
|
||||||
pthread_mutex_lock(&globals.lock);
|
pthread_mutex_lock(&globals.lock);
|
||||||
pw_array_for_each(tmp, &globals.fd_maps) {
|
pw_array_for_each(tmp, &globals.fd_maps) {
|
||||||
if (tmp->file->dev_id == dev) {
|
if (tmp->file->dev_id == dev) {
|
||||||
if (tmp->file->fd == -1)
|
if (tmp->file->closed)
|
||||||
tmp->file->fd = tmp->fd;
|
tmp->file->fd = tmp->fd;
|
||||||
ATOMIC_INC(tmp->file->ref);
|
ATOMIC_INC(tmp->file->ref);
|
||||||
map = tmp;
|
map = tmp;
|
||||||
|
|
@ -901,9 +902,8 @@ static int v4l2_close(int fd)
|
||||||
|
|
||||||
if (fd != file->fd)
|
if (fd != file->fd)
|
||||||
spa_system_close(file->l->system, fd);
|
spa_system_close(file->l->system, fd);
|
||||||
else
|
|
||||||
file->fd = -1;
|
|
||||||
|
|
||||||
|
file->closed = true;
|
||||||
unref_file(file);
|
unref_file(file);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue