va: sort the device queue
authorHaihao Xiang <haihao.xiang@intel.com>
Wed, 27 Jan 2021 07:32:26 +0000 (15:32 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Tue, 2 Feb 2021 02:28:04 +0000 (10:28 +0800)
If so, the elements will be registered per drm node in order of
renderD128, renderD129, ... etc, an element with constant name will be
registered on renderD128 on a hardware with multiple drm nodes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1988>

sys/va/gstvadevice.c

index a00293f..0e251e1 100644 (file)
@@ -55,6 +55,14 @@ gst_va_device_new (GstVaDisplay * display, const gchar * render_device_path)
   return device;
 }
 
+static gint
+compare_device_path (gconstpointer a, gconstpointer b, gpointer user_data)
+{
+  const GstVaDevice *pa = a, *pb = b;
+
+  return strcmp (pa->render_device_path, pb->render_device_path);
+}
+
 GList *
 gst_va_device_find_devices (void)
 {
@@ -80,9 +88,10 @@ gst_va_device_find_devices (void)
       continue;
 
     GST_INFO ("Found VA-API device: %s", path);
-    g_queue_push_tail (&devices, gst_va_device_new (dpy, path));
+    g_queue_push_head (&devices, gst_va_device_new (dpy, path));
   }
 
+  g_queue_sort (&devices, compare_device_path, NULL);
   g_list_free_full (udev_devices, g_object_unref);
   g_object_unref (client);