Fix device probing from multiple childs. It's done once in the parent class only now, but the childs do get the corre...

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.
This commit is contained in:
Ronald S. Bultje 2003-11-09 20:54:24 +00:00
parent 91c4cbfd9b
commit 2676b79eb6
2 changed files with 26 additions and 4 deletions

View file

@ -122,16 +122,17 @@ gst_v4l_class_probe_devices (GstV4lElementClass *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);
}
@ -148,7 +149,7 @@ gst_v4l_class_probe_devices (GstV4lElementClass *klass,
if (fd > 0)
close (fd);
klass->devices = g_list_append (klass->devices, device);
devices = g_list_append (devices, device);
break;
}
}
@ -159,6 +160,8 @@ gst_v4l_class_probe_devices (GstV4lElementClass *klass,
init = TRUE;
}
klass->devices = devices;
return init;
}

View file

@ -38,6 +38,10 @@
#include "gstv4ltuner.h"
#include "gstv4lcolorbalance.h"
#include "gstv4lsrc.h"
#include "gstv4lmjpegsrc.h"
#include "gstv4lmjpegsink.h"
#define DEBUG(format, args...) \
GST_DEBUG_OBJECT (\
GST_ELEMENT(v4lelement), \
@ -130,6 +134,21 @@ gst_v4l_open (GstV4lElement *v4lelement)
return FALSE;
}
/* device type check */
if ((GST_IS_V4LSRC(v4lelement) &&
!(v4lelement->vcap.type & VID_TYPE_CAPTURE)) ||
(GST_IS_V4LMJPEGSRC(v4lelement) &&
!(v4lelement->vcap.type & VID_TYPE_MJPEG_ENCODER)) ||
(GST_IS_V4LMJPEGSINK(v4lelement) &&
!(v4lelement->vcap.type & VID_TYPE_MJPEG_DECODER))) {
gst_element_error(GST_ELEMENT(v4lelement),
"Device opened, but wrong type (0x%x)",
v4lelement->vcap.type);
close(v4lelement->video_fd);
v4lelement->video_fd = -1;
return FALSE;
}
gst_info("Opened device \'%s\' (\'%s\') successfully\n",
v4lelement->vcap.name, v4lelement->videodev);