pipeline: avoid using invalid clock times
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 15 Nov 2010 11:49:05 +0000 (12:49 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 2 Dec 2010 18:10:44 +0000 (19:10 +0100)
Be extra careful to not use invalid clock times but give a warning instead. This
should make things work better with faulty clock implementations.

gst/gstpipeline.c

index 8f5d381..7dd8ba8 100644 (file)
@@ -343,7 +343,13 @@ pipeline_update_start_time (GstElement * element)
     GST_OBJECT_LOCK (element);
     /* store the current running time */
     if (GST_ELEMENT_START_TIME (pipeline) != GST_CLOCK_TIME_NONE) {
-      GST_ELEMENT_START_TIME (pipeline) = now - element->base_time;
+      if (now != GST_CLOCK_TIME_NONE)
+        GST_ELEMENT_START_TIME (pipeline) = now - element->base_time;
+      else
+        GST_WARNING_OBJECT ("Clock %s returned invalid time, can't calculate "
+            "running_time when going to the PAUSED state",
+            GST_OBJECT_NAME (clock));
+
       /* we went to PAUSED, when going to PLAYING select clock and new
        * base_time */
       pipeline->priv->update_clock = TRUE;