v4l2bufferpool: Only queue buffer if preparation worked
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 24 Jul 2018 16:07:22 +0000 (12:07 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Mon, 27 Aug 2018 17:41:30 +0000 (13:41 -0400)
The preparation code imports the buffer, doing bunch of
validation. Only queue the buffer in the driver if the
importation worked. This way we don't rely on the driver
to validate.

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

sys/v4l2/gstv4l2bufferpool.c

index 9eba369..ff08a26 100644 (file)
@@ -1414,11 +1414,14 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
         {
           GstV4l2MemoryGroup *group;
           if (gst_v4l2_is_buffer_valid (buffer, &group)) {
+            GstFlowReturn ret = GST_FLOW_OK;
+
             gst_v4l2_allocator_reset_group (pool->vallocator, group);
             /* queue back in the device */
             if (pool->other_pool)
-              gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL);
-            if (gst_v4l2_buffer_pool_qbuf (pool, buffer, group) != GST_FLOW_OK)
+              ret = gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL);
+            if (ret != GST_FLOW_OK ||
+                gst_v4l2_buffer_pool_qbuf (pool, buffer, group) != GST_FLOW_OK)
               pclass->release_buffer (bpool, buffer);
           } else {
             /* Simply release invalide/modified buffer, the allocator will