basesink: reorganize the code a little
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 19 Jun 2012 14:08:00 +0000 (16:08 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Tue, 19 Jun 2012 14:15:36 +0000 (16:15 +0200)
Move the code to get the sync times together.

libs/gst/base/gstbasesink.c

index f9c66fe..dcf1841 100644 (file)
@@ -1745,7 +1745,6 @@ gst_base_sink_get_sync_times (GstBaseSink * basesink, GstMiniObject * obj,
     gboolean * stepped, GstStepInfo * step, gboolean * step_end)
 {
   GstBaseSinkClass *bclass;
-  GstBuffer *buffer;
   GstClockTime start, stop;     /* raw start/stop timestamps */
   guint64 cstart, cstop;        /* clipped raw timestamps */
   guint64 rstart, rstop;        /* clipped timestamps converted to running time */
@@ -1758,9 +1757,12 @@ gst_base_sink_get_sync_times (GstBaseSink * basesink, GstMiniObject * obj,
   priv = basesink->priv;
   segment = &basesink->segment;
 
+  bclass = GST_BASE_SINK_GET_CLASS (basesink);
+
   /* start with nothing */
   start = stop = GST_CLOCK_TIME_NONE;
 
+again:
   if (G_UNLIKELY (GST_IS_EVENT (obj))) {
     GstEvent *event = GST_EVENT_CAST (obj);
 
@@ -1797,28 +1799,27 @@ gst_base_sink_get_sync_times (GstBaseSink * basesink, GstMiniObject * obj,
         /* other events do not need syncing */
         return FALSE;
     }
-  }
-
-  eos = FALSE;
+  } else {
+    /* else do buffer sync code */
+    GstBuffer *buffer;
 
-again:
-  /* else do buffer sync code */
-  buffer = GST_BUFFER_CAST (obj);
+    eos = FALSE;
 
-  bclass = GST_BASE_SINK_GET_CLASS (basesink);
+    buffer = GST_BUFFER_CAST (obj);
 
-  /* just get the times to see if we need syncing, if the start returns -1 we
-   * don't sync. */
-  if (bclass->get_times)
-    bclass->get_times (basesink, buffer, &start, &stop);
+    /* just get the times to see if we need syncing, if the start returns -1 we
+     * don't sync. */
+    if (bclass->get_times)
+      bclass->get_times (basesink, buffer, &start, &stop);
 
-  if (!GST_CLOCK_TIME_IS_VALID (start)) {
-    /* we don't need to sync but we still want to get the timestamps for
-     * tracking the position */
-    gst_base_sink_default_get_times (basesink, buffer, &start, &stop);
-    *do_sync = FALSE;
-  } else {
-    *do_sync = TRUE;
+    if (!GST_CLOCK_TIME_IS_VALID (start)) {
+      /* we don't need to sync but we still want to get the timestamps for
+       * tracking the position */
+      gst_base_sink_default_get_times (basesink, buffer, &start, &stop);
+      *do_sync = FALSE;
+    } else {
+      *do_sync = TRUE;
+    }
   }
 
   GST_DEBUG_OBJECT (basesink, "got times start: %" GST_TIME_FORMAT