From 50888062ba6bd32e503de2393b7496ba1fcdb26c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 29 Feb 2016 19:04:16 +0000 Subject: [PATCH] info: make it possible to remove default log handler before gst_init() Make sure it's not even added then, so that we never output anything via the default log handler then. https://bugzilla.gnome.org/show_bug.cgi?id=751538 --- gst/gstinfo.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 8bfa33b..d9e9d11 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -253,6 +253,9 @@ LogFuncEntry; static GMutex __log_func_mutex; static GSList *__log_functions = NULL; +/* whether to add the default log function in gst_init() */ +static gboolean add_default_log_func = TRUE; + #define PRETTY_TAGS_DEFAULT TRUE static gboolean pretty_tags = PRETTY_TAGS_DEFAULT; @@ -321,7 +324,8 @@ _priv_gst_debug_init (void) _GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG", GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, "debugging subsystem"); - gst_debug_add_log_function (gst_debug_log_default, log_file, NULL); + if (add_default_log_func) + gst_debug_add_log_function (gst_debug_log_default, log_file, NULL); /* FIXME: add descriptions here */ GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT", @@ -1265,9 +1269,18 @@ gst_debug_remove_log_function (GstLogFunction func) removals = gst_debug_remove_with_compare_func (gst_debug_compare_log_function_by_func, (gpointer) func); - if (gst_is_initialized ()) + + if (gst_is_initialized ()) { GST_DEBUG ("removed log function %p %d times from log function list", func, removals); + } else { + /* If the default log function is removed before gst_init() was called, + * set a flag so we don't add it in gst_init() later */ + if (func == gst_debug_log_default) { + add_default_log_func = FALSE; + ++removals; + } + } return removals; } -- 2.7.4