docs/pwg/advanced-scheduling.xml: Update from 0.9.x to 0.10 API and make example...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 19 Jan 2006 10:39:27 +0000 (10:39 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 19 Jan 2006 10:39:27 +0000 (10:39 +0000)
Original commit message from CVS:
* docs/pwg/advanced-scheduling.xml:
Update from 0.9.x to 0.10 API and make example a bit
clearer.

ChangeLog
docs/pwg/advanced-scheduling.xml

index ea56db9..e7e0215 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-19  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * docs/pwg/advanced-scheduling.xml:
+         Update from 0.9.x to 0.10 API and make example a bit
+         clearer.
+
 2006-01-19  Jan Schmidt  <thaytan@mad.scientist.com>
 
        * docs/gst/gstreamer-sections.txt:
index 2aab690..f24c492 100644 (file)
@@ -254,24 +254,47 @@ gst_my_filter_activate_pull (GstPad  *pad,
 static void
 gst_my_filter_loop (GstMyFilter * filter)
 {
+  GstFlowReturn ret;
   guint64 len;
   GstFormat fmt = GST_FORMAT_BYTES;
   GstBuffer *buf = NULL;
 
-  if (!gst_pad_query_position (filter-&gt;sinkpad, &amp;fmt, NULL, &amp;len)) {
+  if (!gst_pad_query_duration (filter-&gt;sinkpad, &amp;fmt, &amp;len)) {
+    GST_DEBUG_OBJECT (filter, "failed to query duration, pausing");
     goto stop;
-  } else if (filter-&gt;offset >= len) {
-    gst_pad_push_event (filter-&gt;sinkpad, gst_event_new (GST_EVENT_EOS));
-  } else if (gst_pad_pull_range (filter-&gt;sinkpad, filter-&gt;offset,
-                                BLOCKSIZE, &amp;buf) != GST_FLOW_OK ||
-            gst_pad_push (filter-&gt;sinkpad, buf) != GST_FLOW_OK) {
+  }
+
+   if (filter-&gt;offset >= len) {
+    GST_DEBUG_OBJECT (filter, "at end of input, sending EOS, pausing");
+    gst_pad_push_event (filter-&gt;srcpad, gst_event_new_eos ());
+    goto stop;
+  }
+
+  /* now, read BLOCKSIZE bytes from byte offset filter-&gt;offset */
+  ret = gst_pad_pull_range (filter-&gt;sinkpad, filter-&gt;offset,
+      BLOCKSIZE, &amp;buf);
+
+  if (ret != GST_FLOW_OK) {
+    GST_DEBUG_OBJECT (filter, "pull_range failed: %s", gst_flow_get_name (ret));
     goto stop;
-  } else {
-    filter-&gt;offset += BLOCKSIZE;
-    return;
   }
 
+  /* now push buffer downstream */
+  ret = gst_pad_push (filter-&gt;srcpad, buf);
+
+  buf = NULL; /* gst_pad_push() took ownership of buffer */
+
+  if (ret != GST_FLOW_OK) {
+    GST_DEBUG_OBJECT (filter, "pad_push failed: %s", gst_flow_get_name (ret));
+    goto stop;
+  }
+
+  /* everything is fine, increase offset and wait for us to be called again */
+  filter-&gt;offset += BLOCKSIZE;
+  return;
+
 stop:
+  GST_DEBUG_OBJECT (filter, "pausing task");
   gst_pad_pause_task (filter-&gt;sinkpad);
 }
 <!-- example-end task.c j -->