mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
harness: fix indentation and replace stress test function macros
These screw with indentation and seem a bit trivial. Just copy'n'paste.
This commit is contained in:
parent
eaf4153668
commit
0728b219b9
1 changed files with 166 additions and 121 deletions
|
@ -149,21 +149,22 @@ static GstStaticPadTemplate hsinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS_ANY);
|
GST_STATIC_CAPS_ANY);
|
||||||
|
|
||||||
struct _GstHarnessPrivate {
|
struct _GstHarnessPrivate
|
||||||
gchar * element_sinkpad_name;
|
{
|
||||||
gchar * element_srcpad_name;
|
gchar *element_sinkpad_name;
|
||||||
|
gchar *element_srcpad_name;
|
||||||
|
|
||||||
GstCaps * src_caps;
|
GstCaps *src_caps;
|
||||||
GstCaps * sink_caps;
|
GstCaps *sink_caps;
|
||||||
GstPad * sink_forward_pad;
|
GstPad *sink_forward_pad;
|
||||||
|
|
||||||
volatile gint recv_buffers;
|
volatile gint recv_buffers;
|
||||||
volatile gint recv_events;
|
volatile gint recv_events;
|
||||||
volatile gint recv_upstream_events;
|
volatile gint recv_upstream_events;
|
||||||
|
|
||||||
GAsyncQueue * buffer_queue;
|
GAsyncQueue *buffer_queue;
|
||||||
GAsyncQueue * src_event_queue;
|
GAsyncQueue *src_event_queue;
|
||||||
GAsyncQueue * sink_event_queue;
|
GAsyncQueue *sink_event_queue;
|
||||||
|
|
||||||
GstClockTime latency_min;
|
GstClockTime latency_min;
|
||||||
GstClockTime latency_max;
|
GstClockTime latency_max;
|
||||||
|
@ -171,17 +172,17 @@ struct _GstHarnessPrivate {
|
||||||
gboolean drop_buffers;
|
gboolean drop_buffers;
|
||||||
GstClockTime last_push_ts;
|
GstClockTime last_push_ts;
|
||||||
|
|
||||||
GstBufferPool * pool;
|
GstBufferPool *pool;
|
||||||
GstAllocator * allocator;
|
GstAllocator *allocator;
|
||||||
GstAllocationParams allocation_params;
|
GstAllocationParams allocation_params;
|
||||||
GstAllocator * propose_allocator;
|
GstAllocator *propose_allocator;
|
||||||
GstAllocationParams propose_allocation_params;
|
GstAllocationParams propose_allocation_params;
|
||||||
|
|
||||||
gboolean blocking_push_mode;
|
gboolean blocking_push_mode;
|
||||||
GCond blocking_push_cond;
|
GCond blocking_push_cond;
|
||||||
GMutex blocking_push_mutex;
|
GMutex blocking_push_mutex;
|
||||||
|
|
||||||
GPtrArray * stress;
|
GPtrArray *stress;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -341,7 +342,9 @@ gst_harness_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstCaps *caps, *filter = NULL;
|
GstCaps *caps, *filter = NULL;
|
||||||
|
|
||||||
caps = priv->sink_caps ? gst_caps_ref (priv->sink_caps) : gst_caps_new_any ();
|
caps =
|
||||||
|
priv->
|
||||||
|
sink_caps ? gst_caps_ref (priv->sink_caps) : gst_caps_new_any ();
|
||||||
|
|
||||||
gst_query_parse_caps (query, &filter);
|
gst_query_parse_caps (query, &filter);
|
||||||
if (filter != NULL) {
|
if (filter != NULL) {
|
||||||
|
@ -399,7 +402,8 @@ gst_harness_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstCaps *caps, *filter = NULL;
|
GstCaps *caps, *filter = NULL;
|
||||||
|
|
||||||
caps = priv->src_caps ? gst_caps_ref (priv->src_caps) : gst_caps_new_any ();
|
caps =
|
||||||
|
priv->src_caps ? gst_caps_ref (priv->src_caps) : gst_caps_new_any ();
|
||||||
|
|
||||||
gst_query_parse_caps (query, &filter);
|
gst_query_parse_caps (query, &filter);
|
||||||
if (filter != NULL) {
|
if (filter != NULL) {
|
||||||
|
@ -1368,8 +1372,8 @@ gst_harness_create_buffer (GstHarness * h, gsize size)
|
||||||
gst_harness_negotiate (h);
|
gst_harness_negotiate (h);
|
||||||
|
|
||||||
if (priv->pool) {
|
if (priv->pool) {
|
||||||
g_assert_cmpint (gst_buffer_pool_acquire_buffer (priv->pool, &ret, NULL), ==,
|
g_assert_cmpint (gst_buffer_pool_acquire_buffer (priv->pool, &ret, NULL),
|
||||||
GST_FLOW_OK);
|
==, GST_FLOW_OK);
|
||||||
if (gst_buffer_get_size (ret) != size) {
|
if (gst_buffer_get_size (ret) != size) {
|
||||||
GST_DEBUG_OBJECT (h,
|
GST_DEBUG_OBJECT (h,
|
||||||
"use fallback, pool is configured with a different size (%zu != %zu)",
|
"use fallback, pool is configured with a different size (%zu != %zu)",
|
||||||
|
@ -1380,7 +1384,9 @@ gst_harness_create_buffer (GstHarness * h, gsize size)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = gst_buffer_new_allocate (priv->allocator, size, &priv->allocation_params);
|
ret =
|
||||||
|
gst_buffer_new_allocate (priv->allocator, size,
|
||||||
|
&priv->allocation_params);
|
||||||
|
|
||||||
g_assert (ret != NULL);
|
g_assert (ret != NULL);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2466,22 +2472,6 @@ gst_harness_requestpad_thread_free (GstHarnessReqPadThread * t)
|
||||||
(t->running = FALSE, \
|
(t->running = FALSE, \
|
||||||
GPOINTER_TO_UINT (g_thread_join (t->thread)))
|
GPOINTER_TO_UINT (g_thread_join (t->thread)))
|
||||||
|
|
||||||
#define GST_HARNESS_STRESS_FUNC_BEGIN(ID, INIT) \
|
|
||||||
static gpointer \
|
|
||||||
gst_harness_stress_##ID##_func (GstHarnessThread * t) \
|
|
||||||
{ \
|
|
||||||
guint count = 0; \
|
|
||||||
INIT; \
|
|
||||||
\
|
|
||||||
while (t->running) {
|
|
||||||
|
|
||||||
#define GST_HARNESS_STRESS_FUNC_END() \
|
|
||||||
count++; \
|
|
||||||
g_usleep (t->sleep); \
|
|
||||||
} \
|
|
||||||
return GUINT_TO_POINTER (count); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_harness_stress_free (GstHarnessThread * t)
|
gst_harness_stress_free (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
|
@ -2489,127 +2479,182 @@ gst_harness_stress_free (GstHarnessThread * t)
|
||||||
t->freefunc (t);
|
t->freefunc (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (custom, {
|
static gpointer
|
||||||
GstHarnessCustomThread *ct = (GstHarnessCustomThread *) t;
|
gst_harness_stress_custom_func (GstHarnessThread * t)
|
||||||
ct->init (ct, ct->data);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstHarnessCustomThread *ct = (GstHarnessCustomThread *) t;
|
GstHarnessCustomThread *ct = (GstHarnessCustomThread *) t;
|
||||||
ct->callback (ct, ct->data);
|
guint count = 0;
|
||||||
}
|
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (statechange, {})
|
ct->init (ct, ct->data);
|
||||||
|
|
||||||
|
while (t->running) {
|
||||||
|
ct->callback (ct, ct->data);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
gst_harness_stress_statechange_func (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
GstClock *clock = gst_element_get_clock (t->h->element);
|
guint count = 0;
|
||||||
GstIterator *it;
|
|
||||||
gboolean done = FALSE;
|
|
||||||
|
|
||||||
g_assert (gst_element_set_state (t->h->element, GST_STATE_NULL) ==
|
while (t->running) {
|
||||||
GST_STATE_CHANGE_SUCCESS);
|
GstClock *clock = gst_element_get_clock (t->h->element);
|
||||||
g_thread_yield ();
|
GstIterator *it;
|
||||||
|
gboolean done = FALSE;
|
||||||
|
|
||||||
it = gst_element_iterate_sink_pads (t->h->element);
|
g_assert (gst_element_set_state (t->h->element, GST_STATE_NULL) ==
|
||||||
while (!done) {
|
GST_STATE_CHANGE_SUCCESS);
|
||||||
GValue item = G_VALUE_INIT;
|
g_thread_yield ();
|
||||||
switch (gst_iterator_next (it, &item)) {
|
|
||||||
case GST_ITERATOR_OK:
|
it = gst_element_iterate_sink_pads (t->h->element);
|
||||||
{
|
while (!done) {
|
||||||
GstPad *sinkpad = g_value_get_object (&item);
|
GValue item = G_VALUE_INIT;
|
||||||
GstPad *srcpad = gst_pad_get_peer (sinkpad);
|
switch (gst_iterator_next (it, &item)) {
|
||||||
if (srcpad != NULL) {
|
case GST_ITERATOR_OK:
|
||||||
gst_pad_unlink (srcpad, sinkpad);
|
{
|
||||||
gst_pad_link (srcpad, sinkpad);
|
GstPad *sinkpad = g_value_get_object (&item);
|
||||||
gst_object_unref (srcpad);
|
GstPad *srcpad = gst_pad_get_peer (sinkpad);
|
||||||
|
if (srcpad != NULL) {
|
||||||
|
gst_pad_unlink (srcpad, sinkpad);
|
||||||
|
gst_pad_link (srcpad, sinkpad);
|
||||||
|
gst_object_unref (srcpad);
|
||||||
|
}
|
||||||
|
g_value_reset (&item);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
g_value_reset (&item);
|
case GST_ITERATOR_RESYNC:
|
||||||
break;
|
gst_iterator_resync (it);
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_ERROR:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
case GST_ITERATOR_DONE:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case GST_ITERATOR_RESYNC:
|
g_value_unset (&item);
|
||||||
gst_iterator_resync (it);
|
|
||||||
break;
|
|
||||||
case GST_ITERATOR_ERROR:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
case GST_ITERATOR_DONE:
|
|
||||||
done = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
g_value_unset (&item);
|
gst_iterator_free (it);
|
||||||
}
|
|
||||||
gst_iterator_free (it);
|
|
||||||
|
|
||||||
if (clock != NULL) {
|
if (clock != NULL) {
|
||||||
gst_element_set_clock (t->h->element, clock);
|
gst_element_set_clock (t->h->element, clock);
|
||||||
gst_object_unref (clock);
|
gst_object_unref (clock);
|
||||||
|
}
|
||||||
|
g_assert (gst_element_set_state (t->h->element, GST_STATE_PLAYING) ==
|
||||||
|
GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
}
|
}
|
||||||
g_assert (gst_element_set_state (t->h->element, GST_STATE_PLAYING) ==
|
return GUINT_TO_POINTER (count);
|
||||||
GST_STATE_CHANGE_SUCCESS);
|
|
||||||
}
|
}
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (buffer, {
|
static gpointer
|
||||||
GstHarnessPushBufferThread *pt = (GstHarnessPushBufferThread *) t;
|
gst_harness_stress_buffer_func (GstHarnessThread * t)
|
||||||
gchar *sid;
|
|
||||||
/* Push stream start, caps and segment events */
|
|
||||||
sid = g_strdup_printf ("%s-%p", GST_OBJECT_NAME (t->h->element), t->h);
|
|
||||||
g_assert (gst_pad_push_event (t->h->srcpad,
|
|
||||||
gst_event_new_stream_start (sid))); g_free (sid);
|
|
||||||
g_assert (gst_pad_push_event (t->h->srcpad,
|
|
||||||
gst_event_new_caps (pt->caps)));
|
|
||||||
g_assert (gst_pad_push_event (t->h->srcpad,
|
|
||||||
gst_event_new_segment (&pt->segment)));
|
|
||||||
}
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GstHarnessPushBufferThread *pt = (GstHarnessPushBufferThread *) t;
|
GstHarnessPushBufferThread *pt = (GstHarnessPushBufferThread *) t;
|
||||||
gst_harness_push (t->h, pt->func (t->h, pt->data));
|
guint count = 0;
|
||||||
}
|
gchar *sid;
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (event, {})
|
/* Push stream start, caps and segment events */
|
||||||
|
sid = g_strdup_printf ("%s-%p", GST_OBJECT_NAME (t->h->element), t->h);
|
||||||
|
g_assert (gst_pad_push_event (t->h->srcpad,
|
||||||
|
gst_event_new_stream_start (sid)));
|
||||||
|
g_free (sid);
|
||||||
|
g_assert (gst_pad_push_event (t->h->srcpad, gst_event_new_caps (pt->caps)));
|
||||||
|
g_assert (gst_pad_push_event (t->h->srcpad,
|
||||||
|
gst_event_new_segment (&pt->segment)));
|
||||||
|
|
||||||
|
while (t->running) {
|
||||||
|
gst_harness_push (t->h, pt->func (t->h, pt->data));
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
gst_harness_stress_event_func (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
GstHarnessPushEventThread *pet = (GstHarnessPushEventThread *) t;
|
GstHarnessPushEventThread *pet = (GstHarnessPushEventThread *) t;
|
||||||
gst_harness_push_event (t->h, gst_event_ref (pet->event));
|
guint count = 0;
|
||||||
}
|
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (upstream_event, {})
|
while (t->running) {
|
||||||
|
gst_harness_push_event (t->h, gst_event_ref (pet->event));
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
gst_harness_stress_upstream_event_func (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
GstHarnessPushEventThread *pet = (GstHarnessPushEventThread *) t;
|
GstHarnessPushEventThread *pet = (GstHarnessPushEventThread *) t;
|
||||||
gst_harness_push_upstream_event (t->h, gst_event_ref (pet->event));
|
guint count = 0;
|
||||||
}
|
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (property, {})
|
while (t->running) {
|
||||||
|
gst_harness_push_upstream_event (t->h, gst_event_ref (pet->event));
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
gst_harness_stress_property_func (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
GstHarnessPropThread *pt = (GstHarnessPropThread *) t;
|
GstHarnessPropThread *pt = (GstHarnessPropThread *) t;
|
||||||
GValue value = G_VALUE_INIT;
|
guint count = 0;
|
||||||
|
|
||||||
g_object_set_property (G_OBJECT (t->h->element), pt->name, &pt->value);
|
while (t->running) {
|
||||||
|
GValue value = G_VALUE_INIT;
|
||||||
|
|
||||||
g_value_init (&value, G_VALUE_TYPE (&pt->value));
|
g_object_set_property (G_OBJECT (t->h->element), pt->name, &pt->value);
|
||||||
g_object_get_property (G_OBJECT (t->h->element), pt->name, &value);
|
|
||||||
g_value_reset (&value);
|
g_value_init (&value, G_VALUE_TYPE (&pt->value));
|
||||||
|
g_object_get_property (G_OBJECT (t->h->element), pt->name, &value);
|
||||||
|
g_value_reset (&value);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
}
|
}
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
GST_HARNESS_STRESS_FUNC_BEGIN (requestpad, {})
|
static gpointer
|
||||||
|
gst_harness_stress_requestpad_func (GstHarnessThread * t)
|
||||||
{
|
{
|
||||||
GstHarnessReqPadThread *rpt = (GstHarnessReqPadThread *) t;
|
GstHarnessReqPadThread *rpt = (GstHarnessReqPadThread *) t;
|
||||||
GstPad *reqpad;
|
guint count = 0;
|
||||||
|
|
||||||
if (rpt->release)
|
while (t->running) {
|
||||||
gst_harness_requestpad_release_pads (rpt);
|
GstPad *reqpad;
|
||||||
g_thread_yield ();
|
|
||||||
|
|
||||||
reqpad = gst_element_request_pad (t->h->element,
|
if (rpt->release)
|
||||||
rpt->templ, rpt->name, rpt->caps);
|
gst_harness_requestpad_release_pads (rpt);
|
||||||
g_assert (reqpad != NULL);
|
|
||||||
|
|
||||||
rpt->pads = g_slist_prepend (rpt->pads, reqpad);
|
g_thread_yield ();
|
||||||
|
|
||||||
|
reqpad = gst_element_request_pad (t->h->element,
|
||||||
|
rpt->templ, rpt->name, rpt->caps);
|
||||||
|
|
||||||
|
g_assert (reqpad != NULL);
|
||||||
|
|
||||||
|
rpt->pads = g_slist_prepend (rpt->pads, reqpad);
|
||||||
|
|
||||||
|
count++;
|
||||||
|
g_usleep (t->sleep);
|
||||||
|
}
|
||||||
|
return GUINT_TO_POINTER (count);
|
||||||
}
|
}
|
||||||
GST_HARNESS_STRESS_FUNC_END ()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_harness_stress_thread_stop:
|
* gst_harness_stress_thread_stop:
|
||||||
|
|
Loading…
Reference in a new issue