mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
Disable some poisoning, since some plugins rely on undefined behavior
Original commit message from CVS: Disable some poisoning, since some plugins rely on undefined behavior
This commit is contained in:
parent
baa7050fd2
commit
1352e57bf6
3 changed files with 101 additions and 9 deletions
|
@ -241,8 +241,10 @@ void gst_caps_append_structure (GstCaps *caps, GstStructure *structure)
|
|||
g_return_if_fail(caps != NULL);
|
||||
|
||||
if (structure){
|
||||
#if 0 /* disable this, since too many plugins rely on undefined behavior */
|
||||
#ifdef USE_POISONING
|
||||
STRUCTURE_POISON (structure);
|
||||
#endif
|
||||
#endif
|
||||
g_ptr_array_add (caps->structs, structure);
|
||||
}
|
||||
|
@ -578,7 +580,9 @@ GstCaps *gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2)
|
|||
GstStructure *struct1;
|
||||
GstStructure *struct2;
|
||||
GstCaps *dest;
|
||||
//GstCaps *caps;
|
||||
#if 0
|
||||
GstCaps *caps;
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (caps1 != NULL, NULL);
|
||||
g_return_val_if_fail (caps2 != NULL, NULL);
|
||||
|
@ -750,8 +754,10 @@ GstCaps *gst_caps_load_thyself (xmlNodePtr parent)
|
|||
/* utility */
|
||||
void gst_caps_replace (GstCaps **caps, GstCaps *newcaps)
|
||||
{
|
||||
#if 0 /* disable this, since too many plugins rely on undefined behavior */
|
||||
#ifdef USE_POISONING
|
||||
if (newcaps) CAPS_POISON (newcaps);
|
||||
//if (newcaps) CAPS_POISON (newcaps);
|
||||
#endif
|
||||
#endif
|
||||
if (*caps) gst_caps_free(*caps);
|
||||
*caps = newcaps;
|
||||
|
|
|
@ -70,6 +70,7 @@ extern gchar *_gst_progname;
|
|||
static void gst_debug_reset_threshold (gpointer category,
|
||||
gpointer unused);
|
||||
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 */
|
||||
static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT;
|
||||
|
@ -87,10 +88,13 @@ static GSList *__categories = NULL;
|
|||
typedef struct {
|
||||
GstLogFunction func;
|
||||
gpointer user_data;
|
||||
GstDebugLevel max_level;
|
||||
} LogFuncEntry;
|
||||
static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
|
||||
static GSList *__log_functions = NULL;
|
||||
static GstDebugLevel __log_level;
|
||||
|
||||
static GstDebugLevel _gst_debug_max_threshold;
|
||||
static GstAtomicInt __default_level;
|
||||
static GstAtomicInt __use_color;
|
||||
gboolean __gst_debug_enabled = TRUE;
|
||||
|
@ -287,6 +291,7 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
|
|||
g_return_if_fail (function != NULL);
|
||||
g_return_if_fail (format != NULL);
|
||||
|
||||
if (level <= __log_level) {
|
||||
message = g_strdup_vprintf (format, args);
|
||||
handler = __log_functions;
|
||||
while (handler) {
|
||||
|
@ -296,6 +301,7 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level,
|
|||
}
|
||||
g_free (message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* gst_debug_construct_term_color:
|
||||
* @colorinfo: the color info
|
||||
|
@ -440,6 +446,8 @@ gst_debug_add_log_function (GstLogFunction func, gpointer data)
|
|||
entry = g_new (LogFuncEntry, 1);
|
||||
entry->func = func;
|
||||
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
|
||||
* in gst_debug_logv. Another solution is to lock the mutex in gst_debug_logv,
|
||||
* but that is waaay costly.
|
||||
|
@ -449,11 +457,35 @@ gst_debug_add_log_function (GstLogFunction func, gpointer data)
|
|||
g_static_mutex_lock (&__log_func_mutex);
|
||||
list = g_slist_copy (__log_functions);
|
||||
__log_functions = g_slist_prepend (list, entry);
|
||||
__log_level = MAX (__log_level, entry->max_level);
|
||||
g_static_mutex_unlock (&__log_func_mutex);
|
||||
|
||||
GST_DEBUG ("prepended log function %p (user data %p) to log functions",
|
||||
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
|
||||
gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func)
|
||||
{
|
||||
|
@ -468,12 +500,16 @@ gst_debug_compare_log_function_by_data (gconstpointer entry, gconstpointer data)
|
|||
|
||||
return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0;
|
||||
}
|
||||
|
||||
static guint
|
||||
gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
|
||||
{
|
||||
GSList *found;
|
||||
GSList *new;
|
||||
guint removals = 0;
|
||||
GstDebugLevel new_level;
|
||||
GSList *handler;
|
||||
|
||||
g_static_mutex_lock (&__log_func_mutex);
|
||||
new = __log_functions;
|
||||
while ((found = g_slist_find_custom (new, data, func))) {
|
||||
|
@ -485,12 +521,21 @@ gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data)
|
|||
new = g_slist_delete_link (new, found);
|
||||
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. */
|
||||
__log_functions = new;
|
||||
g_static_mutex_unlock (&__log_func_mutex);
|
||||
|
||||
return removals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_debug_remove_log_function:
|
||||
* @func: the log function to remove
|
||||
|
@ -512,6 +557,7 @@ gst_debug_remove_log_function (GstLogFunction func)
|
|||
|
||||
return removals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_debug_remove_log_function_by_data:
|
||||
* @data: user data of the log function to remove
|
||||
|
@ -531,6 +577,7 @@ gst_debug_remove_log_function_by_data (gpointer data)
|
|||
|
||||
return removals;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_debug_set_colored:
|
||||
* @colored: Whether to use colored output or not
|
||||
|
@ -606,6 +653,23 @@ gst_debug_get_default_threshold (void)
|
|||
{
|
||||
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
|
||||
gst_debug_reset_threshold (gpointer category, gpointer unused)
|
||||
{
|
||||
|
@ -627,8 +691,10 @@ gst_debug_reset_threshold (gpointer category, gpointer unused)
|
|||
gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
|
||||
|
||||
exit:
|
||||
gst_debug_recalculate_max_threshold ();
|
||||
g_static_mutex_unlock (&__level_name_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_debug_reset_all_thresholds (void)
|
||||
{
|
||||
|
@ -673,6 +739,7 @@ gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level)
|
|||
g_static_mutex_unlock (&__level_name_mutex);
|
||||
g_static_mutex_lock (&__cat_mutex);
|
||||
g_slist_foreach (__categories, for_each_threshold_by_entry, entry);
|
||||
gst_debug_recalculate_max_threshold ();
|
||||
g_static_mutex_unlock (&__cat_mutex);
|
||||
}
|
||||
/**
|
||||
|
@ -703,6 +770,7 @@ gst_debug_unset_threshold_for_name (const gchar *name)
|
|||
walk = __level_name;
|
||||
}
|
||||
}
|
||||
gst_debug_recalculate_max_threshold ();
|
||||
g_static_mutex_unlock (&__level_name_mutex);
|
||||
g_pattern_spec_free (pat);
|
||||
gst_debug_reset_all_thresholds ();
|
||||
|
|
|
@ -104,6 +104,14 @@ struct _GstDebugCategory {
|
|||
|
||||
/********** 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 */
|
||||
#define GST_STR_NULL(str) ((str) ? (str) : "(NULL)")
|
||||
|
||||
|
@ -162,6 +170,16 @@ void gst_debug_log (GstDebugCategory * category,
|
|||
GObject * object,
|
||||
gchar * format,
|
||||
...) 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,
|
||||
GstDebugLevel level,
|
||||
const gchar * file,
|
||||
|
|
Loading…
Reference in a new issue