mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 01:31:03 +00:00
va: Make libgudev dependency optional.
libgudev is a problematic dependency, particularly in sandboxed environments, such as flatpak. This patch implements a way to get the available VA devices using brute-forced traverse of /dev/drm/renderD* directory. Thus usable in those sandboxed environments. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1027>
This commit is contained in:
parent
e699aaeb16
commit
2e6cd5c2e4
2 changed files with 30 additions and 1 deletions
|
@ -24,7 +24,9 @@
|
|||
|
||||
#include "gstvadevice.h"
|
||||
|
||||
#if HAVE_GUDEV
|
||||
#include <gudev/gudev.h>
|
||||
#endif
|
||||
|
||||
#define GST_CAT_DEFAULT gstva_debug
|
||||
GST_DEBUG_CATEGORY_EXTERN (gstva_debug);
|
||||
|
@ -62,6 +64,7 @@ compare_device_path (gconstpointer a, gconstpointer b, gpointer user_data)
|
|||
return strcmp (pa->render_device_path, pb->render_device_path);
|
||||
}
|
||||
|
||||
#if HAVE_GUDEV
|
||||
GList *
|
||||
gst_va_device_find_devices (void)
|
||||
{
|
||||
|
@ -96,6 +99,31 @@ gst_va_device_find_devices (void)
|
|||
|
||||
return devices.head;
|
||||
}
|
||||
#else
|
||||
GList *
|
||||
gst_va_device_find_devices (void)
|
||||
{
|
||||
GstVaDisplay *dpy;
|
||||
GQueue devices = G_QUEUE_INIT;
|
||||
gchar path[64];
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
g_snprintf (path, sizeof (path), "/dev/dri/renderD%d", 128 + i);
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
continue;
|
||||
|
||||
if (!(dpy = gst_va_display_drm_new_from_path (path)))
|
||||
continue;
|
||||
|
||||
GST_INFO ("Found VA-API device: %s", path);
|
||||
g_queue_push_head (&devices, gst_va_device_new (dpy, path));
|
||||
}
|
||||
|
||||
g_queue_sort (&devices, compare_device_path, NULL);
|
||||
return devices.head;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gst_va_device_list_free (GList * devices)
|
||||
|
|
|
@ -26,7 +26,7 @@ if va_option.disabled() or host_system != 'linux'
|
|||
subdir_done()
|
||||
endif
|
||||
|
||||
libgudev_dep = dependency('gudev-1.0', required: va_option)
|
||||
libgudev_dep = dependency('gudev-1.0', required: false)
|
||||
|
||||
if not gstva_dep.found() or not libgudev_dep.found()
|
||||
if va_option.enabled()
|
||||
|
@ -39,6 +39,7 @@ if libva_dep.version().version_compare('>= 1.8')
|
|||
va_sources += 'gstvaav1dec.c'
|
||||
endif
|
||||
|
||||
cdata.set10('HAVE_GUDEV', libgudev_dep.found())
|
||||
|
||||
driverdir = libva_dep.get_variable(pkgconfig: 'driverdir', internal: 'driverdir', default_value: '')
|
||||
if driverdir == ''
|
||||
|
|
Loading…
Reference in a new issue