v4l2src: handle latency query before setting up the bufferpool
authorSjoerd Simons <sjoerd@luon.net>
Thu, 20 Sep 2012 08:07:24 +0000 (10:07 +0200)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 20 Sep 2012 12:49:42 +0000 (13:49 +0100)
Fixes crash if no bufferpool is set up yet.

https://bugzilla.gnome.org/show_bug.cgi?id=684430

sys/v4l2/gstv4l2src.c

index f31e39d..ce92d36 100644 (file)
@@ -624,7 +624,7 @@ gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query)
     case GST_QUERY_LATENCY:{
       GstClockTime min_latency, max_latency;
       guint32 fps_n, fps_d;
-      guint num_buffers;
+      guint num_buffers = 0;
 
       /* device must be open */
       if (!GST_V4L2_IS_OPEN (obj)) {
@@ -647,7 +647,8 @@ gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query)
       min_latency = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);
 
       /* max latency is total duration of the frame buffer */
-      num_buffers = GST_V4L2_BUFFER_POOL_CAST (obj->pool)->num_buffers;
+      if (obj->pool != NULL)
+        num_buffers = GST_V4L2_BUFFER_POOL_CAST (obj->pool)->num_buffers;
 
       if (num_buffers == 0)
         max_latency = -1;