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:
Tim-Philipp Müller 2015-07-07 15:02:45 +01:00
parent eaf4153668
commit 0728b219b9

View file

@ -149,21 +149,22 @@ static GstStaticPadTemplate hsinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
struct _GstHarnessPrivate {
gchar * element_sinkpad_name;
gchar * element_srcpad_name;
struct _GstHarnessPrivate
{
gchar *element_sinkpad_name;
gchar *element_srcpad_name;
GstCaps * src_caps;
GstCaps * sink_caps;
GstPad * sink_forward_pad;
GstCaps *src_caps;
GstCaps *sink_caps;
GstPad *sink_forward_pad;
volatile gint recv_buffers;
volatile gint recv_events;
volatile gint recv_upstream_events;
GAsyncQueue * buffer_queue;
GAsyncQueue * src_event_queue;
GAsyncQueue * sink_event_queue;
GAsyncQueue *buffer_queue;
GAsyncQueue *src_event_queue;
GAsyncQueue *sink_event_queue;
GstClockTime latency_min;
GstClockTime latency_max;
@ -171,17 +172,17 @@ struct _GstHarnessPrivate {
gboolean drop_buffers;
GstClockTime last_push_ts;
GstBufferPool * pool;
GstAllocator * allocator;
GstBufferPool *pool;
GstAllocator *allocator;
GstAllocationParams allocation_params;
GstAllocator * propose_allocator;
GstAllocator *propose_allocator;
GstAllocationParams propose_allocation_params;
gboolean blocking_push_mode;
GCond blocking_push_cond;
GMutex blocking_push_mutex;
GPtrArray * stress;
GPtrArray *stress;
};
static GstFlowReturn
@ -341,7 +342,9 @@ gst_harness_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
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);
if (filter != NULL) {
@ -399,7 +402,8 @@ gst_harness_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
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);
if (filter != NULL) {
@ -1368,8 +1372,8 @@ gst_harness_create_buffer (GstHarness * h, gsize size)
gst_harness_negotiate (h);
if (priv->pool) {
g_assert_cmpint (gst_buffer_pool_acquire_buffer (priv->pool, &ret, NULL), ==,
GST_FLOW_OK);
g_assert_cmpint (gst_buffer_pool_acquire_buffer (priv->pool, &ret, NULL),
==, GST_FLOW_OK);
if (gst_buffer_get_size (ret) != size) {
GST_DEBUG_OBJECT (h,
"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)
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);
return ret;
@ -2466,22 +2472,6 @@ gst_harness_requestpad_thread_free (GstHarnessReqPadThread * t)
(t->running = FALSE, \
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
gst_harness_stress_free (GstHarnessThread * t)
{
@ -2489,19 +2479,30 @@ gst_harness_stress_free (GstHarnessThread * t)
t->freefunc (t);
}
GST_HARNESS_STRESS_FUNC_BEGIN (custom, {
GstHarnessCustomThread *ct = (GstHarnessCustomThread *) t;
ct->init (ct, ct->data);
}
)
static gpointer
gst_harness_stress_custom_func (GstHarnessThread * t)
{
GstHarnessCustomThread *ct = (GstHarnessCustomThread *) t;
ct->callback (ct, ct->data);
}
GST_HARNESS_STRESS_FUNC_END ()
guint count = 0;
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)
{
guint count = 0;
while (t->running) {
GstClock *clock = gst_element_get_clock (t->h->element);
GstIterator *it;
gboolean done = FALSE;
@ -2545,45 +2546,75 @@ GST_HARNESS_STRESS_FUNC_BEGIN (statechange, {})
}
g_assert (gst_element_set_state (t->h->element, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_SUCCESS);
}
GST_HARNESS_STRESS_FUNC_END ()
GST_HARNESS_STRESS_FUNC_BEGIN (buffer, {
count++;
g_usleep (t->sleep);
}
return GUINT_TO_POINTER (count);
}
static gpointer
gst_harness_stress_buffer_func (GstHarnessThread * t)
{
GstHarnessPushBufferThread *pt = (GstHarnessPushBufferThread *) t;
guint count = 0;
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)));
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;
while (t->running) {
gst_harness_push (t->h, pt->func (t->h, pt->data));
}
GST_HARNESS_STRESS_FUNC_END ()
GST_HARNESS_STRESS_FUNC_BEGIN (event, {})
count++;
g_usleep (t->sleep);
}
return GUINT_TO_POINTER (count);
}
static gpointer
gst_harness_stress_event_func (GstHarnessThread * t)
{
GstHarnessPushEventThread *pet = (GstHarnessPushEventThread *) t;
guint count = 0;
while (t->running) {
gst_harness_push_event (t->h, gst_event_ref (pet->event));
}
GST_HARNESS_STRESS_FUNC_END ()
GST_HARNESS_STRESS_FUNC_BEGIN (upstream_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;
gst_harness_push_upstream_event (t->h, gst_event_ref (pet->event));
}
GST_HARNESS_STRESS_FUNC_END ()
guint count = 0;
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;
guint count = 0;
while (t->running) {
GValue value = G_VALUE_INIT;
g_object_set_property (G_OBJECT (t->h->element), pt->name, &pt->value);
@ -2591,25 +2622,39 @@ GST_HARNESS_STRESS_FUNC_BEGIN (property, {})
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);
}
GST_HARNESS_STRESS_FUNC_END ()
GST_HARNESS_STRESS_FUNC_BEGIN (requestpad, {})
count++;
g_usleep (t->sleep);
}
return GUINT_TO_POINTER (count);
}
static gpointer
gst_harness_stress_requestpad_func (GstHarnessThread * t)
{
GstHarnessReqPadThread *rpt = (GstHarnessReqPadThread *) t;
guint count = 0;
while (t->running) {
GstPad *reqpad;
if (rpt->release)
gst_harness_requestpad_release_pads (rpt);
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: