mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
gst-validate-runner: Add locking for the reports list.
This commit is contained in:
parent
e7315aa78e
commit
855f141453
2 changed files with 35 additions and 4 deletions
|
@ -77,6 +77,8 @@ gst_validate_runner_dispose (GObject * object)
|
|||
g_slist_free_full (runner->reports,
|
||||
(GDestroyNotify) gst_validate_report_unref);
|
||||
|
||||
g_mutex_clear (&runner->mutex);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
@ -100,6 +102,7 @@ gst_validate_runner_init (GstValidateRunner * runner)
|
|||
{
|
||||
runner->setup = FALSE;
|
||||
runner->max_printed_level = GST_VALIDATE_REPORT_LEVEL_NUM_ENTRIES;
|
||||
g_mutex_init (&runner->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +122,9 @@ void
|
|||
gst_validate_runner_add_report (GstValidateRunner * runner,
|
||||
GstValidateReport * report)
|
||||
{
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
runner->reports = g_slist_prepend (runner->reports, report);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
g_signal_emit (runner, _signals[REPORT_ADDED_SIGNAL], 0, report);
|
||||
}
|
||||
|
@ -135,16 +140,27 @@ gst_validate_runner_add_report (GstValidateRunner * runner,
|
|||
guint
|
||||
gst_validate_runner_get_reports_count (GstValidateRunner * runner)
|
||||
{
|
||||
guint l;
|
||||
|
||||
g_return_val_if_fail (runner != NULL, 0);
|
||||
return g_slist_length (runner->reports);
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
l = g_slist_length (runner->reports);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
GSList *
|
||||
gst_validate_runner_get_reports (GstValidateRunner * runner)
|
||||
{
|
||||
/* TODO should we need locking or put in the docs to always call this
|
||||
* after pipeline ends? */
|
||||
return g_slist_reverse (runner->reports);
|
||||
GSList *ret;
|
||||
|
||||
GST_VALIDATE_RUNNER_LOCK (runner);
|
||||
ret = g_slist_reverse (runner->reports);
|
||||
GST_VALIDATE_RUNNER_UNLOCK (runner);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,20 @@ 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
|
||||
|
||||
#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:
|
||||
|
@ -54,6 +68,7 @@ struct _GstValidateRunner {
|
|||
|
||||
gboolean setup;
|
||||
guint max_printed_level;
|
||||
GMutex mutex;
|
||||
|
||||
/*< private >*/
|
||||
GSList *reports;
|
||||
|
|
Loading…
Reference in a new issue