seeking: add more logging for seeking
authorStefan Sauer <ensonic@users.sf.net>
Wed, 27 Feb 2013 21:15:48 +0000 (22:15 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Wed, 27 Feb 2013 21:17:17 +0000 (22:17 +0100)
Especially add logging to error code paths.

gst/gstsegment.c
libs/gst/base/gstbasesink.c
libs/gst/base/gstbasesrc.c

index 9d4fee4..9890be5 100644 (file)
@@ -301,6 +301,8 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
   if (stop != -1) {
     if (start > stop) {
       g_return_val_if_fail (start <= stop, FALSE);
+      GST_WARNING ("segment update failed: start(%" G_GUINT64_FORMAT
+          ") > stop(%" G_GUINT64_FORMAT ")", start, stop);
       return FALSE;
     }
   }
@@ -311,6 +313,7 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
   } else {
     /* remember the elapsed time */
     base = gst_segment_to_running_time (segment, format, position);
+    GST_DEBUG ("updated segment.base: %" G_GUINT64_FORMAT, base);
   }
 
   if (update_start && rate > 0.0) {
@@ -361,6 +364,8 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
   segment->time = start;
   segment->position = position;
 
+  GST_INFO ("segment updated: %" GST_SEGMENT_FORMAT, segment);
+
   return TRUE;
 }
 
@@ -469,8 +474,10 @@ gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
   guint64 start, stop;
   gdouble abs_rate;
 
-  if (G_UNLIKELY (position == -1))
+  if (G_UNLIKELY (position == -1)) {
+    GST_WARNING ("invalid position (-1)");
     return -1;
+  }
 
   g_return_val_if_fail (segment != NULL, -1);
   g_return_val_if_fail (segment->format == format, -1);
@@ -481,27 +488,38 @@ gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
     start += segment->offset;
 
   /* before the segment boundary */
-  if (G_UNLIKELY (position < start))
+  if (G_UNLIKELY (position < start)) {
+    GST_WARNING ("position(%" G_GUINT64_FORMAT ") < start(%" G_GUINT64_FORMAT
+        ")", position, start);
     return -1;
+  }
 
   stop = segment->stop;
 
   if (G_LIKELY (segment->rate > 0.0)) {
-    /* outside of the segment boundary stop */
-    if (G_UNLIKELY (stop != -1 && position > stop))
+    /* after of the segment boundary */
+    if (G_UNLIKELY (stop != -1 && position > stop)) {
+      GST_WARNING ("position(%" G_GUINT64_FORMAT ") > stop(%" G_GUINT64_FORMAT
+          ")", position, stop);
       return -1;
+    }
 
     /* bring to uncorrected position in segment */
     result = position - start;
   } else {
     /* cannot continue if no stop position set or outside of
      * the segment. */
-    if (G_UNLIKELY (stop == -1))
+    if (G_UNLIKELY (stop == -1)) {
+      GST_WARNING ("invalid stop (-1)");
       return -1;
+    }
 
     stop -= segment->offset;
-    if (G_UNLIKELY (position > stop))
+    if (G_UNLIKELY (position > stop)) {
+      GST_WARNING ("position(%" G_GUINT64_FORMAT ") > stop(%" G_GUINT64_FORMAT
+          ")", position, stop);
       return -1;
+    }
 
     /* bring to uncorrected position in segment */
     result = stop - position;
index c7101b2..bea509d 100644 (file)
@@ -2054,8 +2054,8 @@ gst_base_sink_wait_clock (GstBaseSink * sink, GstClockTime time,
   /* FIXME: Casting to GstClockEntry only works because the types
    * are the same */
   if (G_LIKELY (sink->priv->cached_clock_id != NULL
-          && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->
-              priv->cached_clock_id) == clock)) {
+          && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->priv->
+              cached_clock_id) == clock)) {
     if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id,
             time)) {
       gst_clock_id_unref (sink->priv->cached_clock_id);
@@ -3021,7 +3021,7 @@ gst_base_sink_default_event (GstBaseSink * basesink, GstEvent * event)
       /* the newsegment event is needed to bring the buffer timestamps to the
        * stream time and to drop samples outside of the playback segment. */
       gst_event_copy_segment (event, &basesink->segment);
-      GST_DEBUG_OBJECT (basesink, "configured SEGMENT %" GST_SEGMENT_FORMAT,
+      GST_DEBUG_OBJECT (basesink, "configured segment %" GST_SEGMENT_FORMAT,
           &basesink->segment);
       basesink->have_newsegment = TRUE;
       GST_OBJECT_UNLOCK (basesink);
@@ -3674,7 +3674,6 @@ gst_base_sink_perform_seek (GstBaseSink * sink, GstPad * pad, GstEvent * event)
     res = gst_base_sink_default_do_seek (sink, &seeksegment);
   }
 
-
   if (flush) {
     GST_DEBUG_OBJECT (sink, "stop flushing upstream");
     gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
@@ -3694,6 +3693,9 @@ gst_base_sink_perform_seek (GstBaseSink * sink, GstPad * pad, GstEvent * event)
     res = FALSE;
   }
 
+  GST_INFO_OBJECT (sink, "seeking done %d: %" GST_SEGMENT_FORMAT, res,
+      &seeksegment);
+
   /* if successful seek, we update our real segment and push
    * out the new segment. */
   if (res) {
index af6b518..9aea2ce 100644 (file)
@@ -1288,6 +1288,8 @@ gst_base_src_do_seek (GstBaseSrc * src, GstSegment * segment)
 
   bclass = GST_BASE_SRC_GET_CLASS (src);
 
+  GST_INFO_OBJECT (src, "seeking: %" GST_SEGMENT_FORMAT, segment);
+
   if (bclass->do_seek)
     result = bclass->do_seek (src, segment);