Fix device probing from multiple childs. It's done once in the parent class only...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Sun, 9 Nov 2003 20:54:24 +0000 (20:54 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Sun, 9 Nov 2003 20:54:24 +0000 (20:54 +0000)
Original commit message from CVS:
Fix device probing from multiple childs. It's done once in the parent class only now, but the childs do get the correct values. Also fixes an incorrect succesful state change if we opened a v4l device that doesn't have the capabilities that are needed by the plugin.

sys/oss/gstosselement.c
sys/v4l2/gstv4l2element.c

index 6d1e151..9e1814a 100644 (file)
@@ -207,6 +207,7 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
                                    gboolean            check)
 {
   static gboolean init = FALSE;
+  static GList *device_combinations;
 
   if (!init && !check) {
     gchar *dsp_base[] = { "/dev/dsp", "/dev/sound/dsp", NULL };
@@ -214,12 +215,11 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
     GstOssDeviceCombination devices[16];
     gint n;
 
-    while (klass->device_combinations) {
-      GList *item = klass->device_combinations;
+    while (device_combinations) {
+      GList *item = device_combinations;
       GstOssDeviceCombination *combi = item->data;
 
-      klass->device_combinations =
-       g_list_remove (klass->device_combinations, item);
+      device_combinations = g_list_remove (device_combinations, item);
 
       g_free (combi->dsp);
       g_free (combi->mixer);
@@ -261,8 +261,7 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
         combi->mixer = devices[n].mixer;
         devices[n].dsp = devices[n].mixer = NULL;
 
-        klass->device_combinations =
-               g_list_append (klass->device_combinations, combi);
+        device_combinations = g_list_append (device_combinations, combi);
       }
     }
 
@@ -278,6 +277,8 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
     init = TRUE;
   }
 
+  klass->device_combinations = device_combinations;
+
   return init;
 }
 
index c9a8118..53893fa 100644 (file)
@@ -125,16 +125,17 @@ gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
                              gboolean             check)
 {
        static gboolean init = FALSE;
+       static GList *devices = NULL;
 
        if (!init && !check) {
                gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
                gint base, n, fd;
 
-               while (klass->devices) {
-                       GList *item = klass->devices;
+               while (devices) {
+                       GList *item = devices;
                        gchar *device = item->data;
 
-                       klass->devices = g_list_remove (klass->devices, item);
+                       devices = g_list_remove (devices, item);
                        g_free (device);
                }
 
@@ -153,8 +154,8 @@ gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
                                                if (fd > 0)
                                                        close (fd);
 
-                                               klass->devices =
-                                                       g_list_append (klass->devices,
+                                               devices =
+                                                       g_list_append (devices,
                                                                       device);
                                                break;
                                        }
@@ -166,6 +167,8 @@ gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
                init = TRUE;
        }
 
+       klass->devices = devices;
+
        return init;
 }