docs/pwg/advanced-scheduling.xml: Update from 0.9.x to 0.10 API and make example a bit clearer.

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.
This commit is contained in:
Tim-Philipp Müller 2006-01-19 10:39:27 +00:00
parent db47e0d2b6
commit 5fadea40de
2 changed files with 39 additions and 10 deletions

View file

@ -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> 2006-01-19 Jan Schmidt <thaytan@mad.scientist.com>
* docs/gst/gstreamer-sections.txt: * docs/gst/gstreamer-sections.txt:

View file

@ -254,24 +254,47 @@ gst_my_filter_activate_pull (GstPad *pad,
static void static void
gst_my_filter_loop (GstMyFilter * filter) gst_my_filter_loop (GstMyFilter * filter)
{ {
GstFlowReturn ret;
guint64 len; guint64 len;
GstFormat fmt = GST_FORMAT_BYTES; GstFormat fmt = GST_FORMAT_BYTES;
GstBuffer *buf = NULL; 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; 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) {
goto stop;
} else {
filter-&gt;offset += BLOCKSIZE;
return;
} }
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;
}
/* 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: stop:
GST_DEBUG_OBJECT (filter, "pausing task");
gst_pad_pause_task (filter-&gt;sinkpad); gst_pad_pause_task (filter-&gt;sinkpad);
} }
<!-- example-end task.c j --> <!-- example-end task.c j -->