sys/v4l2/gstv4l2src.c: Initialize num_buffers with minimum value.

Original commit message from CVS:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
Initialize num_buffers with minimum value.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame):
Handle frame-size query failure gracefully.
This commit is contained in:
Stefan Kost 2007-07-17 11:35:29 +00:00
parent 82d3eca90b
commit 5d60a17f4a
4 changed files with 33 additions and 12 deletions

View file

@ -1,3 +1,12 @@
2007-07-17 Stefan Kost <ensonic@users.sf.net>
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
Initialize num_buffers with minimum value.
* sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame):
Handle frame-size query failure gracefully.
2007-07-16 Wim Taymans <wim.taymans@gmail.com> 2007-07-16 Wim Taymans <wim.taymans@gmail.com>
* gst/qtdemux/qtdemux.c: (qtdemux_parse_node): * gst/qtdemux/qtdemux.c: (qtdemux_parse_node):

2
common

@ -1 +1 @@
Subproject commit fb4b30ebbec59a8944cacae5fb5cf40bff5dfcaa Subproject commit b3fe2a25c1cd0f4b021795d0db7330aeb338da7c

View file

@ -298,7 +298,7 @@ gst_v4l2src_init (GstV4l2Src * v4l2src, GstV4l2SrcClass * klass)
gst_v4l2_get_input, gst_v4l2_set_input, NULL); gst_v4l2_get_input, gst_v4l2_set_input, NULL);
/* number of buffers requested */ /* number of buffers requested */
v4l2src->num_buffers = 0; v4l2src->num_buffers = 2;
v4l2src->formats = NULL; v4l2src->formats = NULL;
@ -324,6 +324,7 @@ gst_v4l2src_dispose (GObject * object)
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
static void static void
gst_v4l2src_finalize (GstV4l2Src * v4l2src) gst_v4l2src_finalize (GstV4l2Src * v4l2src)
{ {
@ -332,6 +333,7 @@ gst_v4l2src_finalize (GstV4l2Src * v4l2src)
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (v4l2src)); G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (v4l2src));
} }
static void static void
gst_v4l2src_set_property (GObject * object, gst_v4l2src_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec) guint prop_id, const GValue * value, GParamSpec * pspec)

View file

@ -379,6 +379,7 @@ gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src)
v4l2src->formats = g_slist_prepend (v4l2src->formats, format); v4l2src->formats = g_slist_prepend (v4l2src->formats, format);
} }
v4l2src->formats = g_slist_reverse (v4l2src->formats); v4l2src->formats = g_slist_reverse (v4l2src->formats);
GST_DEBUG_OBJECT (v4l2src, "got %d format(s)", n);
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
@ -560,9 +561,10 @@ GstCaps *
gst_v4l2src_probe_caps_for_format (GstV4l2Src * v4l2src, guint32 pixelformat, gst_v4l2src_probe_caps_for_format (GstV4l2Src * v4l2src, guint32 pixelformat,
const GstStructure * template) const GstStructure * template)
{ {
#ifdef VIDIOC_ENUM_FRAMESIZES
GstCaps *ret; GstCaps *ret;
GstStructure *tmp; GstStructure *tmp;
#ifdef VIDIOC_ENUM_FRAMESIZES
gint fd = v4l2src->v4l2object->video_fd; gint fd = v4l2src->v4l2object->video_fd;
struct v4l2_frmsizeenum size; struct v4l2_frmsizeenum size;
guint32 w, h; guint32 w, h;
@ -629,18 +631,17 @@ enum_framesizes_failed:
GST_DEBUG_OBJECT (v4l2src, GST_DEBUG_OBJECT (v4l2src,
"Failed to enumerate frame sizes for pixelformat %" GST_FOURCC_FORMAT "Failed to enumerate frame sizes for pixelformat %" GST_FOURCC_FORMAT
" (%s)", GST_FOURCC_ARGS (pixelformat), g_strerror (errno)); " (%s)", GST_FOURCC_ARGS (pixelformat), g_strerror (errno));
return NULL; goto default_frame_sizes;
} }
unknown_type: unknown_type:
{ {
GST_WARNING_OBJECT (v4l2src, GST_WARNING_OBJECT (v4l2src,
"Unknown frame sizeenum type for pixelformat %" GST_FOURCC_FORMAT "Unknown frame sizeenum type for pixelformat %" GST_FOURCC_FORMAT
": %u", GST_FOURCC_ARGS (pixelformat), size.type); ": %u", GST_FOURCC_ARGS (pixelformat), size.type);
return NULL; goto default_frame_sizes;
} }
#else /* defined VIDIOC_ENUM_FRAMESIZES */ default_frame_sizes:
GstCaps *ret; #endif /* defined VIDIOC_ENUM_FRAMESIZES */
GstStructure *tmp;
/* This code is for Linux < 2.6.19 */ /* This code is for Linux < 2.6.19 */
@ -653,7 +654,6 @@ unknown_type:
(gint) 1, (gint) 100, (gint) 1, NULL); (gint) 1, (gint) 100, (gint) 1, NULL);
gst_caps_append_structure (ret, tmp); gst_caps_append_structure (ret, tmp);
return ret; return ret;
#endif /* defined VIDIOC_ENUM_FRAMESIZES */
} }
/****************************************************** /******************************************************
@ -710,9 +710,17 @@ gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)
else { else {
*/ */
GST_DEBUG_OBJECT (v4l2src, "reenqueing buffer"); GST_DEBUG_OBJECT (v4l2src, "reenqueing buffer");
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_QBUF, &buffer) < 0) { /* FIXME: this is not a good idea, as drivers usualy return the buffer
goto qbuf_failed; * with index-number set to 0, thus the re-enque will fail unless it
} * was incidentialy 0.
* We could try to re-enque all buffers without handling the ioctl
* return.
*/
/*
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_QBUF, &buffer) < 0) {
goto qbuf_failed;
}
*/
/*} */ /*} */
} }
break; break;
@ -820,6 +828,7 @@ too_many_trials:
NUM_TRIALS, v4l2src->v4l2object->videodev, g_strerror (errno))); NUM_TRIALS, v4l2src->v4l2object->videodev, g_strerror (errno)));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
/*
qbuf_failed: qbuf_failed:
{ {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, WRITE, GST_ELEMENT_ERROR (v4l2src, RESOURCE, WRITE,
@ -829,6 +838,7 @@ qbuf_failed:
v4l2src->v4l2object->videodev, g_strerror (errno))); v4l2src->v4l2object->videodev, g_strerror (errno)));
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
*/
} }