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.
This commit is contained in:
Havard Graff 2019-05-22 10:09:47 +02:00
parent 604ea0e711
commit 229b4776ea

View file

@ -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);