From 229b4776ea2c680b114f3934538352e48275be51 Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Wed, 22 May 2019 10:09:47 +0200 Subject: [PATCH] harness: move creating of buffer and event queues to harness itself By only having it on sinkpad-creation, it is racy to write a test with a sometimes-pad (like a demuxer) that you want to pull from, having the pull wait until the pad arrives and the buffer can be produced. --- libs/gst/check/gstharness.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/libs/gst/check/gstharness.c b/libs/gst/check/gstharness.c index b1f734e..be4c228 100644 --- a/libs/gst/check/gstharness.c +++ b/libs/gst/check/gstharness.c @@ -540,13 +540,9 @@ static void gst_harness_setup_src_pad (GstHarness * h, GstStaticPadTemplate * src_tmpl, const gchar * element_sinkpad_name) { - GstHarnessPrivate *priv = h->priv; g_assert (src_tmpl); g_assert (h->srcpad == NULL); - priv->src_event_queue = - g_async_queue_new_full ((GDestroyNotify) gst_event_unref); - /* sending pad */ h->srcpad = gst_pad_new_from_static_template (src_tmpl, "src"); g_assert (h->srcpad); @@ -565,15 +561,9 @@ static void gst_harness_setup_sink_pad (GstHarness * h, GstStaticPadTemplate * sink_tmpl, const gchar * element_srcpad_name) { - GstHarnessPrivate *priv = h->priv; g_assert (sink_tmpl); g_assert (h->sinkpad == NULL); - priv->buffer_queue = g_async_queue_new_full ( - (GDestroyNotify) gst_buffer_unref); - priv->sink_event_queue = g_async_queue_new_full ( - (GDestroyNotify) gst_event_unref); - /* receiving pad */ h->sinkpad = gst_pad_new_from_static_template (sink_tmpl, "sink"); g_assert (h->sinkpad); @@ -668,6 +658,13 @@ gst_harness_new_empty (void) priv->drop_buffers = FALSE; priv->testclock = GST_TEST_CLOCK_CAST (gst_test_clock_new ()); + priv->buffer_queue = g_async_queue_new_full ( + (GDestroyNotify) gst_buffer_unref); + priv->src_event_queue = g_async_queue_new_full ( + (GDestroyNotify) gst_event_unref); + priv->sink_event_queue = g_async_queue_new_full ( + (GDestroyNotify) gst_event_unref); + priv->propose_allocator = NULL; gst_allocation_params_init (&priv->propose_allocation_params); @@ -1067,8 +1064,6 @@ gst_harness_teardown (GstHarness * h) GST_PAD_STREAM_UNLOCK (h->srcpad); gst_object_unref (h->srcpad); - - g_async_queue_unref (priv->src_event_queue); } if (h->sinkpad) { @@ -1087,9 +1082,6 @@ gst_harness_teardown (GstHarness * h) GST_PAD_STREAM_UNLOCK (h->sinkpad); gst_object_unref (h->sinkpad); - - g_async_queue_unref (priv->buffer_queue); - g_async_queue_unref (priv->sink_event_queue); } gst_object_replace ((GstObject **) & priv->propose_allocator, NULL); @@ -1114,6 +1106,10 @@ gst_harness_teardown (GstHarness * h) g_mutex_clear (&priv->blocking_push_mutex); g_mutex_clear (&priv->priv_mutex); + g_async_queue_unref (priv->buffer_queue); + g_async_queue_unref (priv->src_event_queue); + g_async_queue_unref (priv->sink_event_queue); + g_ptr_array_unref (priv->stress); gst_object_unref (h->element); -- 2.7.4