harness: always set our test-clock on the harnessed element
authorHavard Graff <havard.graff@gmail.com>
Wed, 27 Jan 2016 14:16:03 +0000 (15:16 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 15 Feb 2016 10:09:42 +0000 (10:09 +0000)
The integration is already so tight, there is no reason to
not further formalize it!

https://bugzilla.gnome.org/show_bug.cgi?id=761914

libs/gst/check/gstharness.c

index 83ac6a3..3eba313 100644 (file)
@@ -691,11 +691,13 @@ gst_harness_add_element_full (GstHarness * h, GstElement * element,
     GstStaticPadTemplate * hsrc, const gchar * element_sinkpad_name,
     GstStaticPadTemplate * hsink, const gchar * element_srcpad_name)
 {
+  GstClock * element_clock;
   gboolean has_sinkpad, has_srcpad;
 
   g_return_if_fail (element != NULL);
   g_return_if_fail (h->element == NULL);
 
+  element_clock = GST_ELEMENT_CLOCK (element);
   h->element = gst_object_ref (element);
   check_element_type (element, &has_sinkpad, &has_srcpad);
 
@@ -721,17 +723,21 @@ gst_harness_add_element_full (GstHarness * h, GstElement * element,
     g_free (stream_id);
   }
 
+  /* if the element already has a testclock attached,
+     we replace our own with it, if no clock we attach the testclock */
+  if (element_clock) {
+    if (GST_IS_TEST_CLOCK (element_clock)) {
+      gst_object_replace ((GstObject **) & h->priv->testclock,
+          (GstObject *) GST_ELEMENT_CLOCK (element));
+    }
+  } else {
+    gst_harness_use_testclock (h);
+  }
+
   /* don't start sources, they start producing data! */
   if (has_sinkpad)
     gst_harness_play (h);
 
-  /* if the element already has a testclock attached, we replace our own with it */
-  if (GST_ELEMENT_CLOCK (element)
-      && GST_IS_TEST_CLOCK (GST_ELEMENT_CLOCK (element))) {
-    gst_object_replace ((GstObject **) & h->priv->testclock,
-        (GstObject *) GST_ELEMENT_CLOCK (element));
-  }
-
   gst_harness_element_ref (h);
 
   GST_DEBUG_OBJECT (h, "added element to harness %p "
@@ -2101,9 +2107,7 @@ gst_harness_add_src_harness (GstHarness * h,
   if (h->src_harness)
     gst_harness_teardown (h->src_harness);
   h->src_harness = src_harness;
-
   gst_harness_set_forward_pad (h->src_harness, h->srcpad);
-  gst_harness_use_testclock (h->src_harness);
   h->src_harness->priv->has_clock_wait = has_clock_wait;
   gst_harness_set_forwarding (h->src_harness, h->priv->forwarding);
 }
@@ -2296,7 +2300,6 @@ gst_harness_add_sink_harness (GstHarness * h, GstHarness * sink_harness)
   }
   h->sink_harness = sink_harness;
   gst_harness_set_forward_pad (h, h->sink_harness->srcpad);
-  gst_harness_use_testclock (h->sink_harness);
   if (priv->forwarding && h->sinkpad)
     gst_pad_sticky_events_foreach (h->sinkpad, forward_sticky_events, h);
   gst_harness_set_forwarding (h->sink_harness, priv->forwarding);