libs/gst/base/gstbasesink.c: Add fixme regarding EOS in pull mode.
authorWim Taymans <wim.taymans@gmail.com>
Fri, 1 Feb 2008 10:27:10 +0000 (10:27 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 1 Feb 2008 10:27:10 +0000 (10:27 +0000)
Original commit message from CVS:
* libs/gst/base/gstbasesink.c: (gst_base_sink_loop),
(gst_base_sink_get_position_paused):
Add fixme regarding EOS in pull mode.
Fix position reporting in PAUSED for negative rates.

ChangeLog
libs/gst/base/gstbasesink.c

index 234bb22..8bd9cd0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-02-01  Wim Taymans  <wim.taymans@collabora.co.uk>
 
+       * libs/gst/base/gstbasesink.c: (gst_base_sink_loop),
+       (gst_base_sink_get_position_paused):
+       Add fixme regarding EOS in pull mode.
+       Fix position reporting in PAUSED for negative rates.
+
+2008-02-01  Wim Taymans  <wim.taymans@collabora.co.uk>
+
        * gst/gstminiobject.c: (gst_mini_object_replace):
        When replacing a miniobject, do a quick equality check first so that we
        can avoid a ref/unref pair.
index ae0ff22..13eedd4 100644 (file)
@@ -2653,6 +2653,7 @@ paused:
     gst_pad_pause_task (pad);
     /* fatal errors and NOT_LINKED cause EOS */
     if (GST_FLOW_IS_FATAL (result) || result == GST_FLOW_NOT_LINKED) {
+      /* FIXME, we shouldn't post EOS when we are operating in segment mode */
       gst_base_sink_event (pad, gst_event_new_eos ());
       /* EOS does not cause an ERROR message */
       if (result != GST_FLOW_UNEXPECTED) {
@@ -2995,17 +2996,35 @@ static gboolean
 gst_base_sink_get_position_paused (GstBaseSink * basesink, gint64 * cur)
 {
   gboolean res;
+  gint64 time;
+  GstSegment *segment;
 
   *cur = basesink->priv->current_sstart;
+  segment = basesink->abidata.ABI.clip_segment;
 
-  if (*cur != -1)
-    *cur = MAX (*cur, basesink->abidata.ABI.clip_segment->time);
-  else
-    *cur = basesink->abidata.ABI.clip_segment->time;
+  time = segment->time;
 
+  if (*cur != -1) {
+    *cur = MAX (*cur, time);
+    GST_DEBUG_OBJECT (basesink, "POSITION as max: %" GST_TIME_FORMAT
+        ", time %" GST_TIME_FORMAT, GST_TIME_ARGS (*cur), GST_TIME_ARGS (time));
+  } else {
+    /* we have no buffer, use the segment times. */
+    if (segment->rate >= 0.0) {
+      /* forward, next position is always the time of the segment */
+      *cur = time;
+      GST_DEBUG_OBJECT (basesink, "POSITION as time: %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (*cur));
+    } else {
+      /* reverse, next expected timestamp is segment->stop. We use the function
+       * to get things right for negative applied_rates. */
+      *cur =
+          gst_segment_to_stream_time (segment, GST_FORMAT_TIME, segment->stop);
+      GST_DEBUG_OBJECT (basesink, "reverse POSITION: %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (*cur));
+    }
+  }
   res = (*cur != -1);
-  GST_DEBUG_OBJECT (basesink, "POSITION: %" GST_TIME_FORMAT,
-      GST_TIME_ARGS (*cur));
 
   return res;
 }