From 717bbbbe701116af529091db2e1879db2da1d79e Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Fri, 2 May 2014 22:42:54 -0400 Subject: [PATCH] v4l2devicemonitor: Port to use GstV4l2Iterator https://bugzilla.gnome.org/show_bug.cgi?id=727925 --- sys/v4l2/gstv4l2devicemonitor.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sys/v4l2/gstv4l2devicemonitor.c b/sys/v4l2/gstv4l2devicemonitor.c index db2f974f15..ef967bc41f 100644 --- a/sys/v4l2/gstv4l2devicemonitor.c +++ b/sys/v4l2/gstv4l2devicemonitor.c @@ -32,6 +32,7 @@ #include "gstv4l2object.h" #include "v4l2_calls.h" +#include "v4l2-utils.h" #ifdef HAVE_GUDEV #include @@ -162,29 +163,24 @@ static GList * gst_v4l2_device_monitor_probe (GstDeviceMonitor * monitor) { GstV4l2DeviceMonitor *self = GST_V4L2_DEVICE_MONITOR (monitor); + GstV4l2Iterator *it; GList *devices = NULL; - const gchar *dev_base[] = { "/dev/video", "/dev/v4l2/video", NULL }; - gint base, n; - /* - * detect /dev entries - */ - for (n = 0; n < 64; n++) { - for (base = 0; dev_base[base] != NULL; base++) { - gchar *dev = g_strdup_printf ("%s%d", dev_base[base], n); - GstV4l2Device *device; + it = gst_v4l2_iterator_new (); - device = gst_v4l2_device_monitor_probe_device (self, dev, NULL); + while (gst_v4l2_iterator_next (it)) { + GstV4l2Device *device; - if (device) { - gst_object_ref_sink (device); - devices = g_list_prepend (devices, device); - } + device = gst_v4l2_device_monitor_probe_device (self, it->device_path, NULL); - g_free (dev); + if (device) { + gst_object_ref_sink (device); + devices = g_list_prepend (devices, device); } } + gst_v4l2_iterator_free (it); + return devices; }