imagefreeze: Return GST_FLOW_UNEXPECTED when getting a second buffer
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 11 Aug 2010 06:46:14 +0000 (08:46 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 4 Sep 2010 12:52:05 +0000 (14:52 +0200)
This prevents upstream from pushing many useless buffers and makes
it go into EOS state.

gst/imagefreeze/gstimagefreeze.c

index 78ccda0..0db2e86 100644 (file)
@@ -332,8 +332,8 @@ gst_image_freeze_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
       GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",
           gst_flow_get_name (ret));
   } else {
-    /* In this case GstPad will allocate a buffer for us */
-    ret = GST_FLOW_OK;
+    /* Let upstream go EOS if we already have a buffer */
+    ret = GST_FLOW_UNEXPECTED;
   }
 
   gst_object_unref (self);
@@ -687,14 +687,13 @@ static GstFlowReturn
 gst_image_freeze_sink_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstImageFreeze *self = GST_IMAGE_FREEZE (GST_PAD_PARENT (pad));
-  GstFlowReturn ret = GST_FLOW_OK;
 
   GST_OBJECT_LOCK (self);
   if (self->buffer) {
     GST_DEBUG_OBJECT (pad, "Already have a buffer, dropping");
     gst_buffer_unref (buffer);
     GST_OBJECT_UNLOCK (self);
-    return ret;
+    return GST_FLOW_UNEXPECTED;
   }
 
   self->buffer = buffer;
@@ -702,7 +701,7 @@ gst_image_freeze_sink_chain (GstPad * pad, GstBuffer * buffer)
 
   gst_pad_start_task (self->srcpad, (GstTaskFunction) gst_image_freeze_src_loop,
       self->srcpad);
-  return ret;
+  return GST_FLOW_OK;
 }
 
 static void