mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
validate-runner: Hide implementation.
This commit is contained in:
parent
855f141453
commit
1f1cf83af8
3 changed files with 44 additions and 40 deletions
|
@ -56,6 +56,26 @@
|
|||
* ]|
|
||||
*/
|
||||
|
||||
struct _GstValidateRunnerPrivate
|
||||
{
|
||||
GMutex mutex;
|
||||
GSList *reports;
|
||||
};
|
||||
|
||||
#define GST_VALIDATE_RUNNER_LOCK(r) \
|
||||
G_STMT_START { \
|
||||
GST_LOG_OBJECT (r, "About to lock %p", &GST_VALIDATE_RUNNER_CAST(r)->priv->mutex); \
|
||||
(g_mutex_lock (&GST_VALIDATE_RUNNER_CAST(r)->priv->mutex)); \
|
||||
GST_LOG_OBJECT (r, "Acquired lock %p", &GST_VALIDATE_RUNNER_CAST(r)->priv->mutex); \
|
||||
} G_STMT_END
|
||||
|
||||
#define GST_VALIDATE_RUNNER_UNLOCK(r) \
|
||||
G_STMT_START { \
|
||||
GST_LOG_OBJECT (r, "About to unlock %p", &GST_VALIDATE_RUNNER_CAST(r)->priv->mutex); \
|
||||
(g_mutex_unlock (&GST_VALIDATE_RUNNER_CAST(r)->priv->mutex)); \
|
||||
GST_LOG_OBJECT (r, "Released lock %p", &GST_VALIDATE_RUNNER_CAST(r)->priv->mutex); \
|
||||
} G_STMT_END
|
||||
|
||||
#define gst_validate_runner_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstValidateRunner, gst_validate_runner, G_TYPE_OBJECT);
|
||||
|
||||
|
@ -74,10 +94,10 @@ gst_validate_runner_dispose (GObject * object)
|
|||
{
|
||||
GstValidateRunner *runner = GST_VALIDATE_RUNNER_CAST (object);
|
||||
|
||||
g_slist_free_full (runner->reports,
|
||||
g_slist_free_full (runner->priv->reports,
|
||||
(GDestroyNotify) gst_validate_report_unref);
|
||||
|
||||
g_mutex_clear (&runner->mutex);
|
||||
g_mutex_clear (&runner->priv->mutex);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -91,6 +111,8 @@ gst_validate_runner_class_init (GstValidateRunnerClass * klass)
|
|||
|
||||
gobject_class->dispose = gst_validate_runner_dispose;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstValidateRunnerPrivate));
|
||||
|
||||
_signals[REPORT_ADDED_SIGNAL] =
|
||||
g_signal_new ("report-added", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1,
|
||||
|
@ -100,9 +122,9 @@ gst_validate_runner_class_init (GstValidateRunnerClass * klass)
|
|||
static void
|
||||
gst_validate_runner_init (GstValidateRunner * runner)
|
||||
{
|
||||
runner->setup = FALSE;
|
||||
runner->max_printed_level = GST_VALIDATE_REPORT_LEVEL_NUM_ENTRIES;
|
||||
g_mutex_init (&runner->mutex);
|
||||
runner->priv = G_TYPE_INSTANCE_GET_PRIVATE (runner, GST_TYPE_VALIDATE_RUNNER,
|
||||
GstValidateRunnerPrivate);
|
||||
g_mutex_init (&runner->priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +145,7 @@ gst_validate_runner_add_report (GstValidateRunner * runner,
|
|||
GstValidateReport * report)
|
||||
{
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
runner->reports = g_slist_prepend (runner->reports, report);
|
||||
runner->priv->reports = g_slist_prepend (runner->priv->reports, report);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
g_signal_emit (runner, _signals[REPORT_ADDED_SIGNAL], 0, report);
|
||||
|
@ -145,7 +167,7 @@ gst_validate_runner_get_reports_count (GstValidateRunner * runner)
|
|||
g_return_val_if_fail (runner != NULL, 0);
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
l = g_slist_length (runner->reports);
|
||||
l = g_slist_length (runner->priv->reports);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
return l;
|
||||
|
@ -157,7 +179,7 @@ gst_validate_runner_get_reports (GstValidateRunner * runner)
|
|||
GSList *ret;
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
ret = g_slist_reverse (runner->reports);
|
||||
ret = g_slist_reverse (runner->priv->reports);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -41,21 +41,8 @@ G_BEGIN_DECLS
|
|||
#define GST_VALIDATE_RUNNER_CAST(obj) ((GstValidateRunner*)(obj))
|
||||
#define GST_VALIDATE_RUNNER_CLASS_CAST(klass) ((GstValidateRunnerClass*)(klass))
|
||||
|
||||
#define GST_VALIDATE_RUNNER_LOCK(r) \
|
||||
G_STMT_START { \
|
||||
GST_LOG_OBJECT (r, "About to lock %p", &GST_VALIDATE_RUNNER_CAST(r)->mutex); \
|
||||
(g_mutex_lock (&GST_VALIDATE_RUNNER_CAST(r)->mutex)); \
|
||||
GST_LOG_OBJECT (r, "Acquired lock %p", &GST_VALIDATE_RUNNER_CAST(r)->mutex); \
|
||||
} G_STMT_END
|
||||
typedef struct _GstValidateRunnerPrivate GstValidateRunnerPrivate;
|
||||
|
||||
#define GST_VALIDATE_RUNNER_UNLOCK(r) \
|
||||
G_STMT_START { \
|
||||
GST_LOG_OBJECT (r, "About to unlock %p", &GST_VALIDATE_RUNNER_CAST(r)->mutex); \
|
||||
(g_mutex_unlock (&GST_VALIDATE_RUNNER_CAST(r)->mutex)); \
|
||||
GST_LOG_OBJECT (r, "Released lock %p", &GST_VALIDATE_RUNNER_CAST(r)->mutex); \
|
||||
} G_STMT_END
|
||||
|
||||
/* TODO hide this to be opaque? */
|
||||
/**
|
||||
* GstValidateRunner:
|
||||
*
|
||||
|
@ -66,12 +53,7 @@ G_BEGIN_DECLS
|
|||
struct _GstValidateRunner {
|
||||
GObject object;
|
||||
|
||||
gboolean setup;
|
||||
guint max_printed_level;
|
||||
GMutex mutex;
|
||||
|
||||
/*< private >*/
|
||||
GSList *reports;
|
||||
GstValidateRunnerPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,8 +55,8 @@ GST_START_TEST (buffer_before_segment)
|
|||
fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_new ()),
|
||||
GST_FLOW_OK);
|
||||
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
report = runner->reports->data;
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports(runner)), 1);
|
||||
report = gst_validate_runner_get_reports (runner)->data;
|
||||
fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_WARNING);
|
||||
fail_unless_equals_int (report->issue->issue_id,
|
||||
GST_VALIDATE_ISSUE_ID_BUFFER_BEFORE_SEGMENT);
|
||||
|
@ -68,7 +68,7 @@ GST_START_TEST (buffer_before_segment)
|
|||
gst_check_setup_events (srcpad, src, NULL, GST_FORMAT_TIME);
|
||||
fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_new ()),
|
||||
GST_FLOW_OK);
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 1);
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
|
@ -136,8 +136,8 @@ GST_START_TEST (buffer_outside_segment)
|
|||
GST_BUFFER_DURATION (buffer) = GST_SECOND;
|
||||
fail_unless (gst_pad_push (srcpad, buffer));
|
||||
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
report = runner->reports->data;
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 1);
|
||||
report = gst_validate_runner_get_reports (runner)->data;
|
||||
fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_ISSUE);
|
||||
fail_unless_equals_int (report->issue->issue_id,
|
||||
GST_VALIDATE_ISSUE_ID_BUFFER_IS_OUT_OF_SEGMENT);
|
||||
|
@ -146,7 +146,7 @@ GST_START_TEST (buffer_outside_segment)
|
|||
/* Pushing a buffer inside the segment */
|
||||
{
|
||||
fail_unless (gst_pad_push (srcpad, gst_buffer_new ()));
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,13 +206,13 @@ _first_buffer_running_time (gboolean failing)
|
|||
fail_unless (gst_pad_push (srcpad, buffer));
|
||||
|
||||
if (failing) {
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
report = runner->reports->data;
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 1);
|
||||
report = gst_validate_runner_get_reports (runner)->data;
|
||||
fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_WARNING);
|
||||
fail_unless_equals_int (report->issue->issue_id,
|
||||
GST_VALIDATE_ISSUE_ID_FIRST_BUFFER_RUNNING_TIME_IS_NOT_ZERO);
|
||||
} else {
|
||||
assert_equals_int (g_slist_length (runner->reports), 0);
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,13 +317,13 @@ _test_flow_aggregation (GstFlowReturn flow, GstFlowReturn flow1,
|
|||
fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_new ()), demux_flow);
|
||||
|
||||
if (should_fail) {
|
||||
assert_equals_int (g_slist_length (runner->reports), 1);
|
||||
report = runner->reports->data;
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 1);
|
||||
report = gst_validate_runner_get_reports (runner)->data;
|
||||
fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_CRITICAL);
|
||||
fail_unless_equals_int (report->issue->issue_id,
|
||||
GST_VALIDATE_ISSUE_ID_WRONG_FLOW_RETURN);
|
||||
} else {
|
||||
assert_equals_int (g_slist_length (runner->reports), 0);
|
||||
assert_equals_int (g_slist_length (gst_validate_runner_get_reports (runner)), 0);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue