basetransform: don't pass NULL outcaps to transform_size on shutdown
authorTim-Philipp Müller <tim@centricular.net>
Sat, 16 Feb 2013 23:02:21 +0000 (23:02 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 21 Feb 2013 11:28:12 +0000 (11:28 +0000)
gst_pad_get_current_caps() on the source pad might yield NULL caps
if we're being shut down and the source pad has already been
deactivated by the other thread that's changing state. Just bail
out in that case, instead of passing NULL caps to the transform_size
function, which it might not expect.

Fixes spurious warnings in audioresample shutdown unit test.

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

libs/gst/base/gstbasetransform.c

index ae779ad..f143970 100644 (file)
@@ -1574,6 +1574,10 @@ default_prepare_output_buffer (GstBaseTransform * trans,
   incaps = gst_pad_get_current_caps (trans->sinkpad);
   outcaps = gst_pad_get_current_caps (trans->srcpad);
 
+  /* srcpad might be flushing already if we're being shut down */
+  if (outcaps == NULL)
+    goto no_outcaps;
+
   GST_DEBUG_OBJECT (trans, "getting output size for alloc");
   /* copy transform, figure out the output size */
   insize = gst_buffer_get_size (inbuf);
@@ -1602,7 +1606,6 @@ done:
   return GST_FLOW_OK;
 
   /* ERRORS */
-  /* ERRORS */
 activate_failed:
   {
     GST_ELEMENT_ERROR (trans, RESOURCE, SETTINGS,
@@ -1619,6 +1622,12 @@ alloc_failed:
     GST_DEBUG_OBJECT (trans, "could not allocate buffer from pool");
     return ret;
   }
+no_outcaps:
+  {
+    GST_DEBUG_OBJECT (trans, "no output caps, source pad has been deactivated");
+    gst_caps_unref (incaps);
+    return GST_FLOW_FLUSHING;
+  }
 }
 
 typedef struct