gst/base/gstbasesink.c: Don't use invalid stream_time.
authorWim Taymans <wim.taymans@gmail.com>
Tue, 25 Oct 2005 10:15:45 +0000 (10:15 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 25 Oct 2005 10:15:45 +0000 (10:15 +0000)
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_get_position):
Don't use invalid stream_time.

* gst/gstevent.c: (gst_event_new_newsegment):
stream_time in newsegment cannot be undefined.

ChangeLog
gst/base/gstbasesink.c
gst/gstevent.c
libs/gst/base/gstbasesink.c

index 67ca270..832d7b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-10-25  Wim Taymans  <wim@fluendo.com>
+
+       * gst/base/gstbasesink.c: (gst_base_sink_get_position):
+       Don't use invalid stream_time.
+
+       * gst/gstevent.c: (gst_event_new_newsegment):
+       stream_time in newsegment cannot be undefined.
+
 2005-10-24  Wim Taymans  <wim@fluendo.com>
 
        * gst/gstbus.c:
index ccbe570..9d5345a 100644 (file)
@@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
       GST_LOCK (basesink);
       if ((clock = GST_ELEMENT_CLOCK (basesink))) {
         GstClockTime now;
+        gint64 segment_time;
 
         gst_object_ref (clock);
         GST_UNLOCK (basesink);
@@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
         now = gst_clock_get_time (clock);
 
         GST_LOCK (basesink);
-        *cur =
-            now - GST_ELEMENT_CAST (basesink)->base_time +
-            basesink->segment_time;
+        if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time))
+          segment_time = basesink->segment_time;
+        else
+          segment_time = 0;
+
+        *cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time;
 
         GST_DEBUG_OBJECT (basesink,
             "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %"
             GST_TIME_FORMAT, GST_TIME_ARGS (now),
-            GST_TIME_ARGS (basesink->segment_time), GST_TIME_ARGS (*cur));
+            GST_TIME_ARGS (segment_time), GST_TIME_ARGS (*cur));
 
         gst_object_unref (clock);
 
index cefad04..64c252a 100644 (file)
@@ -398,8 +398,9 @@ gst_event_new_eos (void)
  * used intelligently by plugins to use more efficient methods of skipping
  * unneeded packets.
  *
- * The stream time of the segment is also used to convert the buffer timestamps
- * into the stream time again.
+ * The stream time of the segment is used to convert the buffer timestamps
+ * into the stream time again, this is usually done in sinks to report the 
+ * current stream_time. @stream_time cannot be -1.
  *
  * The @start_value cannot be -1, the @stop_value can be -1. If there
  * is a valid @stop_value given, it must be greater or equal than @start_value.
@@ -429,6 +430,9 @@ gst_event_new_newsegment (gboolean update, gdouble rate, GstFormat format,
         "start %lld, stop %lld, stream_time %lld",
         update, rate, format, start_value, stop_value, stream_time);
   }
+  if (stream_time == -1)
+    g_return_val_if_fail (stream_time != -1, NULL);
+
   if (start_value == -1)
     g_return_val_if_fail (start_value != -1, NULL);
 
index ccbe570..9d5345a 100644 (file)
@@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
       GST_LOCK (basesink);
       if ((clock = GST_ELEMENT_CLOCK (basesink))) {
         GstClockTime now;
+        gint64 segment_time;
 
         gst_object_ref (clock);
         GST_UNLOCK (basesink);
@@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
         now = gst_clock_get_time (clock);
 
         GST_LOCK (basesink);
-        *cur =
-            now - GST_ELEMENT_CAST (basesink)->base_time +
-            basesink->segment_time;
+        if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time))
+          segment_time = basesink->segment_time;
+        else
+          segment_time = 0;
+
+        *cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time;
 
         GST_DEBUG_OBJECT (basesink,
             "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %"
             GST_TIME_FORMAT, GST_TIME_ARGS (now),
-            GST_TIME_ARGS (basesink->segment_time), GST_TIME_ARGS (*cur));
+            GST_TIME_ARGS (segment_time), GST_TIME_ARGS (*cur));
 
         gst_object_unref (clock);