[cheese] Fix non usb device detection



commit a6b681b1807eb51b2721f772e83a4a72291fe367
Author: Filippo Argiolas <filippo argiolas gmail com>
Date:   Sat Dec 12 08:42:09 2009 +0100

    Fix non usb device detection
    
    Product and Vendor id, usb specific, are used just for debugging, no need to
    ignore devices that don't provide them.

 libcheese/cheese-camera-device-monitor.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/libcheese/cheese-camera-device-monitor.c b/libcheese/cheese-camera-device-monitor.c
index 6b9a1bb..0babe99 100644
--- a/libcheese/cheese-camera-device-monitor.c
+++ b/libcheese/cheese-camera-device-monitor.c
@@ -90,6 +90,7 @@ cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
   const char             *gstreamer_src, *product_name;
   const char             *vendor;
   const char             *product;
+  const char             *bus;
   gint                    vendor_id     = 0;
   gint                    product_id    = 0;
   gint                    v4l_version   = 0;
@@ -97,21 +98,26 @@ cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
 
   g_print ("Checking udev device '%s'\n", g_udev_device_get_property (udevice, "DEVPATH"));
 
-  vendor = g_udev_device_get_property (udevice, "ID_VENDOR_ID");
-  if (vendor != NULL)
-    vendor_id = g_ascii_strtoll (vendor, NULL, 16);
-  product = g_udev_device_get_property (udevice, "ID_MODEL_ID");
-  if (product != NULL)
-    product_id = g_ascii_strtoll (vendor, NULL, 16);
-  if (vendor_id == 0 || product_id == 0) {
-    g_warning ("error getting product or vendor id");
-    return;
+  bus = g_udev_device_get_property (udevice, "ID_BUS");
+  if (g_strcmp0 (bus, "usb") == 0) {
+    vendor = g_udev_device_get_property (udevice, "ID_VENDOR_ID");
+    if (vendor != NULL)
+      vendor_id = g_ascii_strtoll (vendor, NULL, 16);
+    product = g_udev_device_get_property (udevice, "ID_MODEL_ID");
+    if (product != NULL)
+      product_id = g_ascii_strtoll (vendor, NULL, 16);
+    if (vendor_id == 0 || product_id == 0) {
+      g_print ("Error getting vendor and product id\n");
+    } else {
+      g_print ("Found device %04x:%04x, getting capabilities...\n", vendor_id, product_id);
+    }
+  } else {
+    g_print ("Not an usb device, skipping vendor and model id retrieval\n");
   }
-  g_print ("Found device %04x:%04x, getting capabilities...\n", vendor_id, product_id);
 
   device_path = g_udev_device_get_device_file (udevice);
   if (device_path == NULL) {
-    g_warning ("error getting V4L device");
+    g_warning ("Error getting V4L device");
     return;
   }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]