Revert last change, because it was unintended.

Original commit message from CVS:
Revert last change, because it was unintended.
This commit is contained in:
David Schleef 2004-01-06 21:41:05 +00:00
parent 1352e57bf6
commit aa40b1516b
2 changed files with 7 additions and 93 deletions

View file

@ -70,7 +70,6 @@ extern gchar *_gst_progname;
static void gst_debug_reset_threshold (gpointer category, static void gst_debug_reset_threshold (gpointer category,
gpointer unused); gpointer unused);
static void gst_debug_reset_all_thresholds (void); static void gst_debug_reset_all_thresholds (void);
static void gst_debug_set_log_function_level (GstLogFunction func, gpointer data, GstDebugLevel level);
/* list of all name/level pairs from --gst-debug and GST_DEBUG */ /* list of all name/level pairs from --gst-debug and GST_DEBUG */
static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT; static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT;
@ -88,13 +87,10 @@ static GSList *__categories = NULL;
typedef struct { typedef struct {
GstLogFunction func; GstLogFunction func;
gpointer user_data; gpointer user_data;
GstDebugLevel max_level;
} LogFuncEntry; } LogFuncEntry;
static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT; static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
static GSList *__log_functions = NULL; static GSList *__log_functions = NULL;
static GstDebugLevel __log_level;
static GstDebugLevel _gst_debug_max_threshold;
static GstAtomicInt __default_level; static GstAtomicInt __default_level;
static GstAtomicInt __use_color; static GstAtomicInt __use_color;
gboolean __gst_debug_enabled = TRUE; gboolean __gst_debug_enabled = TRUE;
@ -291,7 +287,6 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
g_return_if_fail (function != NULL); g_return_if_fail (function != NULL);
g_return_if_fail (format != NULL); g_return_if_fail (format != NULL);
if (level <= __log_level) {
message = g_strdup_vprintf (format, args); message = g_strdup_vprintf (format, args);
handler = __log_functions; handler = __log_functions;
while (handler) { while (handler) {
@ -300,7 +295,6 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
entry->func (category, level, file, function, line, object, message, entry->user_data); entry->func (category, level, file, function, line, object, message, entry->user_data);
} }
g_free (message); g_free (message);
}
} }
/** /**
* gst_debug_construct_term_color: * gst_debug_construct_term_color:
@ -446,8 +440,6 @@ gst_debug_add_log_function (GstLogFunction func, gpointer data)
entry = g_new (LogFuncEntry, 1); entry = g_new (LogFuncEntry, 1);
entry->func = func; entry->func = func;
entry->user_data = data; entry->user_data = data;
//entry->max_level = GST_LEVEL_LOG;
entry->max_level = 0;
/* FIXME: we leak the old list here - other threads might access it right now /* FIXME: we leak the old list here - other threads might access it right now
* in gst_debug_logv. Another solution is to lock the mutex in gst_debug_logv, * in gst_debug_logv. Another solution is to lock the mutex in gst_debug_logv,
* but that is waaay costly. * but that is waaay costly.
@ -457,35 +449,11 @@ gst_debug_add_log_function (GstLogFunction func, gpointer data)
g_static_mutex_lock (&__log_func_mutex); g_static_mutex_lock (&__log_func_mutex);
list = g_slist_copy (__log_functions); list = g_slist_copy (__log_functions);
__log_functions = g_slist_prepend (list, entry); __log_functions = g_slist_prepend (list, entry);
__log_level = MAX (__log_level, entry->max_level);
g_static_mutex_unlock (&__log_func_mutex); g_static_mutex_unlock (&__log_func_mutex);
GST_DEBUG ("prepended log function %p (user data %p) to log functions", GST_DEBUG ("prepended log function %p (user data %p) to log functions",
func, data); func, data);
} }
static void
gst_debug_set_log_function_level (GstLogFunction func, gpointer data, GstDebugLevel level)
{
LogFuncEntry *entry;
GSList *list;
GstDebugLevel new_level;
g_static_mutex_lock (&__log_func_mutex);
list = __log_functions;
new_level = 0;
while (list) {
entry = list->data;
if (entry->func == func && entry->user_data == data) {
entry->max_level = level;
}
new_level = MAX (new_level, entry->max_level);
list = g_slist_next (list);
}
__log_level = new_level;
g_static_mutex_unlock (&__log_func_mutex);
}
static gint static gint
gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func) gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func)
{ {
@ -500,16 +468,12 @@ gst_debug_compare_log_function_by_data (gconstpointer entry, gconstpointer data)
return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0; return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0;
} }
static guint static guint
gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data) gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
{ {
GSList *found; GSList *found;
GSList *new; GSList *new;
guint removals = 0; guint removals = 0;
GstDebugLevel new_level;
GSList *handler;
g_static_mutex_lock (&__log_func_mutex); g_static_mutex_lock (&__log_func_mutex);
new = __log_functions; new = __log_functions;
while ((found = g_slist_find_custom (new, data, func))) { while ((found = g_slist_find_custom (new, data, func))) {
@ -521,21 +485,12 @@ gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
new = g_slist_delete_link (new, found); new = g_slist_delete_link (new, found);
removals++; removals++;
} }
new_level = 0;
handler = new;
while (handler) {
LogFuncEntry *entry = handler->data;
new_level = MAX (entry->max_level, new_level);
handler = g_slist_next (handler);
}
__log_level = new_level;
/* FIXME: We leak the old list here. See _add_log_function for why. */ /* FIXME: We leak the old list here. See _add_log_function for why. */
__log_functions = new; __log_functions = new;
g_static_mutex_unlock (&__log_func_mutex); g_static_mutex_unlock (&__log_func_mutex);
return removals; return removals;
} }
/** /**
* gst_debug_remove_log_function: * gst_debug_remove_log_function:
* @func: the log function to remove * @func: the log function to remove
@ -557,7 +512,6 @@ gst_debug_remove_log_function (GstLogFunction func)
return removals; return removals;
} }
/** /**
* gst_debug_remove_log_function_by_data: * gst_debug_remove_log_function_by_data:
* @data: user data of the log function to remove * @data: user data of the log function to remove
@ -577,7 +531,6 @@ gst_debug_remove_log_function_by_data (gpointer data)
return removals; return removals;
} }
/** /**
* gst_debug_set_colored: * gst_debug_set_colored:
* @colored: Whether to use colored output or not * @colored: Whether to use colored output or not
@ -653,23 +606,6 @@ gst_debug_get_default_threshold (void)
{ {
return (GstDebugLevel) gst_atomic_int_read (&__default_level); return (GstDebugLevel) gst_atomic_int_read (&__default_level);
} }
static void
gst_debug_recalculate_max_threshold (void)
{
GSList *walk;
GstDebugLevel new_threshold = 0;
walk = __categories;
while (walk) {
GstDebugCategory *cat = walk->data;
new_threshold = MAX (gst_atomic_int_read (cat->threshold), new_threshold);
walk = g_slist_next (walk);
}
_gst_debug_max_threshold = new_threshold;
gst_debug_set_log_function_level (gst_debug_log_default, NULL,
_gst_debug_max_threshold);
}
static void static void
gst_debug_reset_threshold (gpointer category, gpointer unused) gst_debug_reset_threshold (gpointer category, gpointer unused)
{ {
@ -691,10 +627,8 @@ gst_debug_reset_threshold (gpointer category, gpointer unused)
gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ()); gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
exit: exit:
gst_debug_recalculate_max_threshold ();
g_static_mutex_unlock (&__level_name_mutex); g_static_mutex_unlock (&__level_name_mutex);
} }
static void static void
gst_debug_reset_all_thresholds (void) gst_debug_reset_all_thresholds (void)
{ {
@ -739,7 +673,6 @@ gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level)
g_static_mutex_unlock (&__level_name_mutex); g_static_mutex_unlock (&__level_name_mutex);
g_static_mutex_lock (&__cat_mutex); g_static_mutex_lock (&__cat_mutex);
g_slist_foreach (__categories, for_each_threshold_by_entry, entry); g_slist_foreach (__categories, for_each_threshold_by_entry, entry);
gst_debug_recalculate_max_threshold ();
g_static_mutex_unlock (&__cat_mutex); g_static_mutex_unlock (&__cat_mutex);
} }
/** /**
@ -770,7 +703,6 @@ gst_debug_unset_threshold_for_name (const gchar *name)
walk = __level_name; walk = __level_name;
} }
} }
gst_debug_recalculate_max_threshold ();
g_static_mutex_unlock (&__level_name_mutex); g_static_mutex_unlock (&__level_name_mutex);
g_pattern_spec_free (pat); g_pattern_spec_free (pat);
gst_debug_reset_all_thresholds (); gst_debug_reset_all_thresholds ();

View file

@ -104,14 +104,6 @@ struct _GstDebugCategory {
/********** some convenience macros for debugging **********/ /********** some convenience macros for debugging **********/
#define GST_TEMP_STRING(str, statement) G_STMT_START { \
char * str = NULL; \
statement; \
g_free( str ); \
} G_STMT_END
/* This is needed in printf's if a char* might be NULL. Solaris crashes then */ /* This is needed in printf's if a char* might be NULL. Solaris crashes then */
#define GST_STR_NULL(str) ((str) ? (str) : "(NULL)") #define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
@ -170,16 +162,6 @@ void gst_debug_log (GstDebugCategory * category,
GObject * object, GObject * object,
gchar * format, gchar * format,
...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT; ...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
void gst_debug_log_callback (GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
char * (*callback)(gpointer callback_arg),
gpointer callback_arg,
gchar * format,
...) G_GNUC_PRINTF (9, 10) G_GNUC_NO_INSTRUMENT;
void gst_debug_log_valist (GstDebugCategory * category, void gst_debug_log_valist (GstDebugCategory * category,
GstDebugLevel level, GstDebugLevel level,
const gchar * file, const gchar * file,