diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2017-12-02 12:22:47 +0000 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-12-06 16:39:28 +0200 |
commit | 5682141f0fdba60ebb0477dd25d1e493f66981c0 (patch) | |
tree | 874de12389b455725ded7cceb1da7b6e8e8d81b2 | |
parent | 2d0a1669b3ec8b03f97b19fbf38b4102386ff904 (diff) |
info: fix performance issue with registering categories after gst_init()
When registering a new debug category after gst_init(), simply check
the existing patterns against that new category.
No need to iterate over all categories and recheck them all against
the existing patterns.
Also, no need to re-parse the existing pattern string set via GST_DEBUG
and add the same set of match patterns all over again to the existing
list of match patterns every time we register a new debug category.
Combined with iterating all debug categories on a change this would
make adding debug categories after gst_init() very very very slow.
-rw-r--r-- | gst/gstinfo.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 5becf4f755..48c9ca8c03 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -1692,6 +1692,18 @@ gst_debug_unset_threshold_for_name (const gchar * name) gst_debug_reset_all_thresholds (); } +static void +gst_debug_apply_patterns_to_category (GstDebugCategory * cat) +{ + GSList *l; + + g_mutex_lock (&__level_name_mutex); + for (l = __level_name; l != NULL; l = l->next) { + for_each_threshold_by_entry (cat, (LevelNameEntry *) l->data); + } + g_mutex_unlock (&__level_name_mutex); +} + GstDebugCategory * _gst_debug_category_new (const gchar * name, guint color, const gchar * description) @@ -1726,7 +1738,7 @@ _gst_debug_category_new (const gchar * name, guint color, /* ensure the filter is applied to categories registered after _debug_init */ if (_gst_debug_filter) { - gst_debug_set_threshold_from_string (_gst_debug_filter, FALSE); + gst_debug_apply_patterns_to_category (cat); } return cat; |