Loop in pullregion until the desired buffer has been pulled.
authorWim Taymans <wim.taymans@gmail.com>
Wed, 13 Jun 2001 21:33:31 +0000 (21:33 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 13 Jun 2001 21:33:31 +0000 (21:33 +0000)
Original commit message from CVS:
Loop in pullregion until the desired buffer has been pulled.

gst/gstpad.c

index eb7d921..0240f46 100644 (file)
@@ -1520,21 +1520,34 @@ gst_pad_pull (GstPad *pad)
 GstBuffer*
 gst_pad_pullregion (GstPad *pad, GstRegionType type, guint64 offset, guint64 len) 
 {
-  GstRealPad *peer = GST_RPAD_PEER(pad);
+  GstRealPad *peer;
+  GstBuffer *result = NULL;
   
   g_return_val_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SINK, NULL);
-  g_return_val_if_fail (peer != NULL, NULL);
 
-  GST_DEBUG_ENTER("(%s:%s,%d,%lld,%lld)",GST_DEBUG_PAD_NAME(pad),type,offset,len);
+  do {
+    peer = GST_RPAD_PEER(pad);
+    g_return_val_if_fail (peer != NULL, NULL);
+
+    if (result) 
+      gst_buffer_unref (result);
+
+    GST_DEBUG_ENTER("(%s:%s,%d,%lld,%lld)",GST_DEBUG_PAD_NAME(pad),type,offset,len);
 
-  if (peer->pullregionfunc) {
-    GST_DEBUG (GST_CAT_DATAFLOW,"calling pullregionfunc &%s of peer pad %s:%s\n",
+    if (peer->pullregionfunc) {
+      GST_DEBUG (GST_CAT_DATAFLOW,"calling pullregionfunc &%s of peer pad %s:%s\n",
           GST_DEBUG_FUNCPTR_NAME(peer->pullregionfunc),GST_DEBUG_PAD_NAME(((GstPad*)peer)));
-    return (peer->pullregionfunc)(((GstPad*)peer),type,offset,len);
-  } else {
-    GST_DEBUG (GST_CAT_DATAFLOW,"no pullregionfunc\n");
-    return NULL;
+      result = (peer->pullregionfunc)(((GstPad*)peer),type,offset,len);
+    } else {
+      GST_DEBUG (GST_CAT_DATAFLOW,"no pullregionfunc\n");
+      result = NULL;
+      break;
+    }
   }
+  while (!(GST_BUFFER_OFFSET (result) == offset && 
+          GST_BUFFER_SIZE (result) == len));
+
+  return result;
 }
 #endif