mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
v4l2: cleanup and simplify
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
This commit is contained in:
parent
996f8a5832
commit
395749fea9
1 changed files with 13 additions and 14 deletions
|
|
@ -787,24 +787,28 @@ static int v4l2_dup(int oldfd)
|
||||||
return do_dup(oldfd, FD_MAP_DUP);
|
return do_dup(oldfd, FD_MAP_DUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int v4l2_openat(int dirfd, const char *requested_path, int oflag, mode_t mode)
|
static int v4l2_openat(int dirfd, const char *path, int oflag, mode_t mode)
|
||||||
{
|
{
|
||||||
int res, flags;
|
int res, flags;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
bool passthrough = true;
|
bool passthrough = true;
|
||||||
uint32_t dev_id = SPA_ID_INVALID;
|
uint32_t dev_id = SPA_ID_INVALID;
|
||||||
char *path;
|
char *real_path;
|
||||||
|
|
||||||
path = realpath(requested_path, NULL);
|
real_path = realpath(path, NULL);
|
||||||
if (path == NULL)
|
if (!real_path)
|
||||||
path = (char *)requested_path;
|
real_path = (char *)path;
|
||||||
|
|
||||||
if (spa_strstartswith(path, "/dev/video")) {
|
if (spa_strstartswith(real_path, "/dev/video")) {
|
||||||
if (spa_atou32(path+10, &dev_id, 10) && dev_id < MAX_DEV)
|
if (spa_atou32(real_path+10, &dev_id, 10) && dev_id < MAX_DEV)
|
||||||
passthrough = false;
|
passthrough = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (real_path && real_path != path)
|
||||||
|
free(real_path);
|
||||||
|
|
||||||
if (passthrough)
|
if (passthrough)
|
||||||
return globals.old_fops.openat(dirfd, requested_path, oflag, mode);
|
return globals.old_fops.openat(dirfd, path, oflag, mode);
|
||||||
|
|
||||||
pw_log_info("path:%s oflag:%d mode:%d", path, oflag, mode);
|
pw_log_info("path:%s oflag:%d mode:%d", path, oflag, mode);
|
||||||
|
|
||||||
|
|
@ -882,9 +886,6 @@ static int v4l2_openat(int dirfd, const char *requested_path, int oflag, mode_t
|
||||||
add_dev_for_serial(file->dev_id, file->serial);
|
add_dev_for_serial(file->dev_id, file->serial);
|
||||||
unref_file(file);
|
unref_file(file);
|
||||||
|
|
||||||
if (path != NULL && path != requested_path)
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
error_unlock:
|
error_unlock:
|
||||||
|
|
@ -897,10 +898,8 @@ error:
|
||||||
pw_log_info("path:%s oflag:%d mode:%d -> %d (%s)", path, oflag, mode,
|
pw_log_info("path:%s oflag:%d mode:%d -> %d (%s)", path, oflag, mode,
|
||||||
-1, spa_strerror(res));
|
-1, spa_strerror(res));
|
||||||
|
|
||||||
if (path != NULL && path != requested_path)
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
errno = -res;
|
errno = -res;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue