Cleaned up INFO system some more, added API to select categories, modified the printout function to print cleanly for...

Original commit message from CVS:
Cleaned up INFO system some more, added API to select categories, modified
the printout function to print cleanly for GST_INIT info (the default min)
and spew function:line debug_string [element] for everything else.
Eventually could make even that configurable easily enough, just check
against another bitmap instead of checking for == GST_INIT.
This commit is contained in:
Erik Walthinsen 2001-01-01 00:17:21 +00:00
parent 527525a282
commit e0aa5bae14
5 changed files with 65 additions and 98 deletions

View file

@ -96,7 +96,7 @@ GstPlugin *plugin_init (GModule *module)
i++; i++;
} }
INFO (0,"gstelements: loaded %d standard elements", i); // INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
return plugin; return plugin;
} }

View file

@ -37,29 +37,39 @@ void gst_cpuid_i386(int,long *,long *,long *,long *);
#define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c); #define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c);
#endif #endif
static gchar *stringcat (gchar *a,gchar *b) {
gchar *c;
if (a) {
c = g_strconcat(a,b);
g_free(a);
} else
c = g_strdup(b);
return c;
}
void void
_gst_cpu_initialize (void) _gst_cpu_initialize (void)
{ {
gchar *featurelist = NULL;
long eax=0, ebx=0, ecx=0, edx=0; long eax=0, ebx=0, ecx=0, edx=0;
gst_cpuid(1, &eax, &ebx, &ecx, &edx); gst_cpuid(1, &eax, &ebx, &ecx, &edx);
g_print("CPU features : ");
if (edx & (1<<23)) { if (edx & (1<<23)) {
_gst_cpu_flags |= GST_CPU_FLAG_MMX; _gst_cpu_flags |= GST_CPU_FLAG_MMX;
g_print("MMX "); featurelist = stringcat(featurelist,"MMX ");
} }
if (edx & (1<<25)) { if (edx & (1<<25)) {
_gst_cpu_flags |= GST_CPU_FLAG_SSE; _gst_cpu_flags |= GST_CPU_FLAG_SSE;
g_print("SSE "); featurelist = stringcat(featurelist,"SSE ");
} }
if (!_gst_cpu_flags) { if (!_gst_cpu_flags) {
g_print("NONE"); featurelist = stringcat(featurelist,"NONE");
} }
g_print("\n");
INFO(GST_INFO_GST_INIT, "CPU features: %s",featurelist);
} }
GstCPUFlags GstCPUFlags

View file

@ -34,7 +34,7 @@ GHashTable *__gst_function_pointers = NULL;
/***** INFO system *****/ /***** INFO system *****/
GstInfoHandler _gst_info_handler = gst_default_info_handler; GstInfoHandler _gst_info_handler = gst_default_info_handler;
//guint32 _gst_info_categories = 0xffffffff; //guint32 _gst_info_categories = 0xffffffff;
guint32 _gst_info_categories = 0x00000000; guint32 _gst_info_categories = 0x00000001;
static gchar *_gst_info_category_strings[] = { static gchar *_gst_info_category_strings[] = {
"GST_INIT", "GST_INIT",
@ -67,102 +67,53 @@ gst_default_info_handler (gint category, gchar *file, gchar *function,
gint line, gchar *debug_string, gint line, gchar *debug_string,
void *element, gchar *string) void *element, gchar *string)
{ {
if (element) { gchar *empty = "";
if (debug_string) gchar *elementname = empty,*location = empty;
fprintf(stderr,"INFO:%s:%d%s: [%s] %s\n",
function,line,debug_string,gst_element_get_name(element),string); if (debug_string == NULL) debug_string = "";
else if (category != GST_INFO_GST_INIT)
fprintf(stderr,"INFO:%s:%d: [%s] %s\n", location = g_strdup_printf("%s:%d%s:",function,line,debug_string);
function,line,gst_element_get_name(element),string); if (element && GST_IS_ELEMENT (element))
} else { elementname = g_strdup_printf (" [%s]",gst_element_get_name (element));
if (debug_string)
fprintf(stderr,"INFO:%s:%d%s: %s\n", fprintf(stderr,"INFO:%s%s %s\n",location,elementname,string);
function,line,debug_string,string);
else if (location != empty) g_free(location);
fprintf(stderr,"INFO:%s:%d: %s\n", if (elementname != empty) g_free(elementname);
function,line,string);
}
g_free(string); g_free(string);
} }
void
gst_info_set_categories (guint32 categories) {
_gst_info_categories = categories;
}
guint32
gst_info_get_categories () {
return _gst_info_categories;
}
const gchar *
gst_info_get_category_name (gint category) {
return _gst_info_category_strings[category];
}
void
gst_info_enable_category (gint category) {
_gst_info_categories |= (1 << category);
}
void
gst_info_disable_category (gint category) {
_gst_info_categories &= ~ (1 << category);
}
/***** ERROR system *****/ /***** ERROR system *****/
GstErrorHandler _gst_error_handler = gst_default_error_handler; GstErrorHandler _gst_error_handler = gst_default_error_handler;
/*
gchar *gst_object_get_path_string(GstObject *object) {
GSList *parentage = NULL;
GSList *parents;
void *parent;
gchar *prevpath, *path = "";
const char *component;
gchar *separator = "";
gboolean free_component;
parentage = g_slist_prepend (NULL, object);
// first walk the object hierarchy to build a list of the parents
do {
if (GST_IS_OBJECT(object)) {
if (GST_IS_PAD(object)) {
parent = GST_PAD(object)->parent;
// } else if (GST_IS_ELEMENT(object)) {
// parent = gst_element_get_parent(GST_ELEMENT(object));
} else {
parent = gst_object_get_parent (object);
}
} else {
parentage = g_slist_prepend (parentage, NULL);
parent = NULL;
}
if (parent != NULL) {
parentage = g_slist_prepend (parentage, parent);
}
object = parent;
} while (object != NULL);
// then walk the parent list and print them out
parents = parentage;
while (parents) {
if (GST_IS_OBJECT(parents->data)) {
if (GST_IS_PAD(parents->data)) {
component = gst_pad_get_name(GST_PAD(parents->data));
separator = ".";
free_component = FALSE;
} else if (GST_IS_ELEMENT(parents->data)) {
component = gst_element_get_name(GST_ELEMENT(parents->data));
separator = "/";
free_component = FALSE;
} else {
// component = g_strdup_printf("a %s",gtk_type_name(gtk_identifier_get_type(parents->data)));
component = g_strdup_printf("unknown%p",parents->data);
separator = "/";
free_component = TRUE;
}
} else {
component = g_strdup_printf("%p",parents->data);
separator = "/";
free_component = TRUE;
}
prevpath = path;
path = g_strjoin(separator,prevpath,component,NULL);
g_free(prevpath);
if (free_component)
g_free((gchar *)component);
parents = g_slist_next(parents);
}
g_slist_free(parentage);
return path;
}
*/
void void
gst_default_error_handler (gchar *file, gchar *function, gst_default_error_handler (gchar *file, gchar *function,
gint line, gchar *debug_string, gint line, gchar *debug_string,

View file

@ -2,7 +2,7 @@
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be> * 2000 Wim Taymans <wtay@chello.be>
* *
* gstdebug.h: Debugging helper macros * gstinfo.h:
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -193,6 +193,12 @@ extern guint32 _gst_info_categories;
}G_STMT_END }G_STMT_END
void gst_info_set_categories (guint32 categories);
guint32 gst_info_get_categories ();
const gchar * gst_info_get_category_name (gint category);
void gst_info_enable_category (gint category);
void gst_info_disable_category (gint category);
enum { enum {
GST_INFO_GST_INIT = 0, // Library initialization GST_INFO_GST_INIT = 0, // Library initialization
GST_INFO_COTHREADS, // Cothread creation, etc. GST_INFO_COTHREADS, // Cothread creation, etc.

View file

@ -96,7 +96,7 @@ GstPlugin *plugin_init (GModule *module)
i++; i++;
} }
INFO (0,"gstelements: loaded %d standard elements", i); // INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
return plugin; return plugin;
} }