diff --git a/ChangeLog b/ChangeLog index ea56db9510..e7e0215dc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-19 Tim-Philipp Müller + + * 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 * docs/gst/gstreamer-sections.txt: diff --git a/docs/pwg/advanced-scheduling.xml b/docs/pwg/advanced-scheduling.xml index 2aab6909e1..f24c492702 100644 --- a/docs/pwg/advanced-scheduling.xml +++ b/docs/pwg/advanced-scheduling.xml @@ -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->sinkpad, &fmt, NULL, &len)) { + if (!gst_pad_query_duration (filter->sinkpad, &fmt, &len)) { + GST_DEBUG_OBJECT (filter, "failed to query duration, pausing"); goto stop; - } else if (filter->offset >= len) { - gst_pad_push_event (filter->sinkpad, gst_event_new (GST_EVENT_EOS)); - } else if (gst_pad_pull_range (filter->sinkpad, filter->offset, - BLOCKSIZE, &buf) != GST_FLOW_OK || - gst_pad_push (filter->sinkpad, buf) != GST_FLOW_OK) { - goto stop; - } else { - filter->offset += BLOCKSIZE; - return; } + if (filter->offset >= len) { + GST_DEBUG_OBJECT (filter, "at end of input, sending EOS, pausing"); + gst_pad_push_event (filter->srcpad, gst_event_new_eos ()); + goto stop; + } + + /* now, read BLOCKSIZE bytes from byte offset filter->offset */ + ret = gst_pad_pull_range (filter->sinkpad, filter->offset, + BLOCKSIZE, &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->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->offset += BLOCKSIZE; + return; + stop: + GST_DEBUG_OBJECT (filter, "pausing task"); gst_pad_pause_task (filter->sinkpad); }